
-----------------------------------
Banished_Outlaw
Fri May 04, 2007 9:44 pm

Determining the color of an object
-----------------------------------
How can i determine the color of an object i drew? I have a program in which rain drops are falling down. They are in a loop and I cannot use cls to erase the droplets because that erases everything i have in the background. The only other way i could think of is to draw the raindrops again with their color matching the color of the object drawn in the background so that it appears that they have vanished. Can anyone tell me how i can do this?

-----------------------------------
Cervantes
Fri May 04, 2007 10:19 pm

RE:Determining the color of an object
-----------------------------------
You have two options, as I see it. One is to record the data about what you have drawn. That is, store the colour and position of the rain drops that have already been drawn, then cls and redraw them. The other option is to use whatdotcolour. Without further knowledge of your purpose, I don't think I can decide which is better. The answer to your initial question is whatdotcolour, but I suspect storing the data is better for your purposes.

-----------------------------------
Banished_Outlaw
Sat May 05, 2007 5:35 pm

Re: Determining the color of an object
-----------------------------------
How do i record the color of the objects i draw?  I dont think i can use cls because cls clears everything and i do not want that happening.  This is what i have so far:


%BACKGROUND
drawfillbox (0, 0, maxx, maxy, 16)
%GROUND
drawfillbox (0, 0, maxx, round (maxy / 2.5), 6)
%STEPHEN LEACOCK
var font := Font.New ("comic sans:16:bold,underline")
drawfillbox (40, 162, 180, 320, grey)
drawfillbox (180, 162, 450, 380, grey)
drawfillbox (400, 162, 600, 320, grey)
drawbox (40, 162, 180, 320, red)
drawbox (180, 162, 450, 380, red)
drawbox (450, 162, 600, 320, red)
Font.Draw ("SCHOOL NAME", 195, 350, font, brightblue)
%FACE
drawfilloval (320, 300, 25, 35, white)
%LEFT EAR
drawfilloval (300, 300, 8, 10, white)
%RIGHT EAR
drawfilloval (340, 300, 8, 10, white)
%NECK
drawfillbox (310, 265, 330, 275, white)
%STOMACH
drawfilloval (320, 200, 30, 70, white)
%LEFT THIGH
drawfilloval (304, 120, 10, 70, white)
%RIGHT THIGH
drawfilloval (336, 120, 10, 70, white)
%RIGHT HAND
drawfilloval (275, 240, 60, 8, white)
%LEFT HAND
drawfilloval (365, 240, 60, 8, white)
%LEFT EYE
drawfilloval (308, 305, 8, 5, brightred)
%LEFT IRIS
drawfilloval (308, 305, 2, 2, white)
%LEFT EYEBROW
drawarc (308, 298, 10, 20, 25, 150, black)
%RIGHT EYE
drawfilloval (332, 305, 8, 5, brightred)
%RIGHT IRIS
drawfilloval (332, 305, 2, 2, white)
%RIGHT EYEBROW
drawarc (332, 298, 10, 20, 25, 150, black)
%NOSE
drawfillbox (315, 294, 325, 298, black)
%MOUTH
drawfilloval (320, 285, 8, 5, black)

drawfilloval (320, 215, 30, 60, white)

drawfilloval (320, 215, 30, 60, white)

drawfilloval (320, 215, 30, 60, white)

process bloodrain
    var x : int
    var y : int := 500
    for k : 1 .. 100000
        randint (x, 0, maxx)
        %randint (y, 0, maxy)
        drawfilloval (x, y, 2, 4, brightred)
        delay (100)
        y := y - 20
        if y = 0 then
            y := 500
        end if
    end for
end bloodrain

process bloodfill
    for j : 1 .. 100000
        delay (100)
        drawfillbox (0, 0, maxx, round (j), brightred)
        if j > 72 then
            %MOUTH
            drawfilloval (320, 282, 10, 8, white)
            drawfilloval (320, 285, 9, 7, black)
            %RIGHT HAND
            drawfilloval (275, 240, 60, 8, grey)
            %LEFT HAND
            drawfilloval (365, 240, 60, 8, grey)
            %STOMACH
            drawfilloval (320, 200, 30, 70, white)
            %RIGHT HAND
            drawfilloval (275, 240, 30, 10, white)
            %LEFT HAND
            drawfilloval (365, 240, 30, 10, white)
            %RIGHT HAND
            drawfilloval (250, 272, 8, 40, white)
            %LEFT HAND
            drawfilloval (390, 272, 8, 40, white)
        end if
        if j > 140 then
            drawfilloval (320, 282, 10, 20, black)
            drawfillbox (0, 0, maxx, round (j), brightred)
        end if
    end for
end bloodfill

fork bloodrain
fork bloodfill


-----------------------------------
Cervantes
Sat May 05, 2007 7:38 pm

RE:Determining the color of an object
-----------------------------------
I'm saying you record the data, cls, then redraw it.

To record the data, you'd probably want to use a flexible array of records. Check out the [Turing Walkthrough] for links to tutorials on these subjects.

Also, please, don't use processes. It is not necessary for something like this, and there are many downsides to them. Read more [url=http://www.compsci.ca/v3/viewtopic.php?t=7842]here.

-----------------------------------
Geostigma
Sat May 05, 2007 10:22 pm

RE:Determining the color of an object
-----------------------------------
Why can't you use cls again? have your rain drops in a array and if spawns a drop then have a procedure to make it move x amount of pixels...

-----------------------------------
Banished_Outlaw
Sun May 06, 2007 9:30 am

Re: Determining the color of an object
-----------------------------------
But this is supposed to be a fairly easy project where I only have to draw some stuff. A bit of animation is allowed and we also have not covered records yet. I read the walk through and its really helpful but I don't want to spend time making records as it is due tomorrow. But thanks a lot for your help. You guys really know a lot. I'm just probably gonna let the rain drops stay on the screen or remove the rain and make a lightning thing in a process and fork it.

-----------------------------------
Cervantes
Sun May 06, 2007 11:02 am

RE:Determining the color of an object
-----------------------------------
As you wish, but that's a really awful way to do it. It hurts my head to consider it. :(

-----------------------------------
Banished_Outlaw
Mon May 07, 2007 9:35 pm

Re: Determining the color of an object
-----------------------------------
lol dun worry i got really good marks on the project...just gotta do some more commenting...and a pseudocode...but we have started doing records and two dimensional arrays now..so if i get time i will try making the program better  :D
