Computer Science Canada paint bucket... desparate help |
Author: | moomoocow [ Fri Mar 04, 2005 9:58 pm ] | ||
Post subject: | paint bucket... desparate help | ||
how do I get the flood fill to change colour? right now it only works as grey and also if there's nothing on the screen, it covers the complete screen. help plz, thx a lot. btw, the topic below mine also about the bucket, is kinda different and the code's rilly confusing so that's why i made a new topic. |
Author: | zylum [ Fri Mar 04, 2005 11:11 pm ] |
Post subject: | |
http://www.compsci.ca/v2/viewtopic.php?t=7959 |
Author: | moomoocow [ Sat Mar 05, 2005 12:17 pm ] |
Post subject: | |
thx, but i saw that thread already. it's different from my problem... |
Author: | Andy [ Sat Mar 05, 2005 12:42 pm ] |
Post subject: | |
no it isnt.. do you even know what drawfill does? |
Author: | moomoocow [ Sat Mar 05, 2005 1:47 pm ] |
Post subject: | |
yeah, i tried your spray and bucket, they don't work with mine. |
Author: | McKenzie [ Sat Mar 05, 2005 3:06 pm ] | ||
Post subject: | |||
OK so as you know drawfill looks like:
so you have to accept that if you are going to use drawfill to do your paint bucket that it MUST be outlined all in the same colour (borderColor.) By your code it looks like you have them backwards. It looks like you want to fill in colour "clur". So put that as your fillColor. From here you need to figure out what your fill colour is. I would suggest that you use whatdotcolour to check the colour of the pixel where you want to start doing the fill then run a loop to check each pixel to the left (right,up, down, doesn't matter) until you find a pixel of a different colour. That different colour is your fillColour. Andy is right, the flood fill allows you to fill an area that is bounded by different colours, but I like the solution I outlined because its easier to get your head around it without needing a solid understanding of recursion. |
Author: | moomoocow [ Sat Mar 05, 2005 6:09 pm ] | ||
Post subject: | |||
ok i fixed the first part, like when it was all grey. thx a lot, but i really don't get how to do the whatdotcolor part...
|
Author: | McKenzie [ Sat Mar 05, 2005 6:43 pm ] | ||
Post subject: | |||
When you click on the spot that you want to fill you need to
|
Author: | moomoocow [ Sun Mar 06, 2005 11:23 am ] | ||
Post subject: | |||
i'm about to give up. it's too hard, sir, but this is better than last time.
|
Author: | McKenzie [ Sun Mar 06, 2005 5:39 pm ] | ||||
Post subject: | |||||
Don't give up, you'll get it. Lets focus on the heart of the problem:
Your if checks if the bucket is selected and you are in clicking inside your drawing canvas. In pseudocode here is what you need to find the bounding colour:
|