Computer Science Canada

RGB.AddColour

Author:  ftm [ Thu Jul 24, 2003 12:05 am ]
Post subject:  RGB.AddColour

ok i've been playing with RGB.AddColour

i cant get it to work

for example :
code:

var blah := RGB.AddColour (1, 0, 0)

put blah
Draw.FillBox (1, 1, 200, 200, blah)


gives me a black box, but if i do it like this:


code:

var blah := RGB.AddColour (1, 0, 0)
RGB.SetColour (blah, 1, 0, 0)

put blah
Draw.FillBox (1, 1, 200, 200, blah)


i get the red box that i expected...

but ! this code works:

code:

var clr : int
for blueShade : 0 .. 15
    clr := RGB.AddColor (0, 0, blueShade / 15)
    if clr = 1 then
        put "Color add failed on shade number ", blueShade
        exit
    else
        colour (clr)
        put "Added color number ", clr
    end if
end for


so basically what is up with that?

p.s. there were no errors, i.e. i checked that blah (used earlier) was 256 not 1 or 0 or whatever the fail code is...

Author:  PaddyLong [ Thu Jul 24, 2003 12:28 am ]
Post subject: 

I think it's a bug with the thing, because I have also experienced problems with adding some colours that end up coming out black

Author:  AsianSensation [ Thu Jul 24, 2003 1:46 pm ]
Post subject: 

it's not a bug, for some strange reason....

code:
var clr := RGB.AddColour (1, 0, 0)

put clr
Draw.FillBox (1, 1, 200, 200, clr)


press f1 several times in a row and you see what happens...

(for me, the color of the box kept on changing...)

RGB.AddColor add a new color to the existing ones, namely, it adds to maxcolor, and maxcolor always change, because you add to it. It changes once you run the program again.

I think RGB.AddColor adds the color based on maxcolor, and since the default maxcolor is black, you add alot of red to it, it should turn out red, but if you add more red shade to a different color, then it will turn out differently. Anyways, that's just my hypothesis.

Author:  JayLo [ Fri Jul 25, 2003 1:13 am ]
Post subject: 

since there are 256 colours by default...

i'm guessing...
code:

var clr : int
for i:1..254
clr := RGB.AddColour (i/255,0,0)
colour (clr)
put "Jay Lo"
end for

correct me if i'm wrong.


: