In order to get some discussion going again, here's a potentially
useful little routine for generating graduated colours under GD2. This
is written for QPC2-style MODE 32 (I don't have a Q40 or Q60 to try an
equivalent mode 33 or an SMSQ/E to handle 256 colour modes) and
generates a gradually changing colour hue from black to the 8 colours
of mode 8. The effect is quite nice - the routine generates seven
blocks of colour in a 128x64 pixel block:

Black to blue
Black to red
Black to magenta
Black to green
Black to cyan
Black to yellow
Black to white

This is but the result of half an hour's tinkering, no doubt someone
will take this routine and substantially improve on it. Remember, if
using QPC2 for example you have to start in high colour mode. Start
the routine with GRAD to see it in action. The routine is reasonably
well commented to help explain how it works if you wish to try to
write your own routines.

(If anyone's unable to save this listing from the email, I can send it
provately as an attachment as I didn't want to send attachments to
this list)

1000 DEFine PROCedure Grad
1010   REMark #1 allows 8 blocks of 128x64 pixels
1020   WINDOW 256,256,256,0 : CLS : CLS #0
1030   REMark r1,g1,b1 are start colours
1040   REMark r2,g2,b2 are end colours
1050   REMark Mode 32: red=0-31,green=0-63,blue=0-31
1060   r1 = 0  : g1 = 0  : b1 = 0
1070   r2 = 31 : g2 = 63 : b2 = 31
1080   REMark size of colour gradient step per line of pixels down
1090   REMark (end_colour-start_colour+1)/steps
1100   rstep = (r2-r1+1)/64
1110   gstep = (g2-g1+1)/64
1120   bstep = (b2-b1+1)/64
1130   REMark do 64 pixel high clocks of graduated colour
1140   FOR y = 0 TO 63
1150     red   = INT((r1+(y*rstep))+.5)    : REMark red component
1160     IF red > r2 THEN red = r2         : REMark rounding errors?
1170     green = INT((g1+(y*gstep))+.5)    : REMark green component
1180     IF green > g2 THEN green = g2     : REMark rounding errors?
1190     blue  = INT((b1+(y*bstep))+.5)    : REMark blue component
1200     IF blue > b2 THEN blue = b2       : REMark rounding errors?
1210     nat_col=(2048*red)+(32*green)+blue: REMark combined native
colour
1220     BLOCK 128,1,0,y,2048*red               : REMark black to red
1230     BLOCK 128,1,128,y,2048*red+blue        : REMark black to
magenta
1240     BLOCK 128,1,0,y+64,32*green            : REMark black to
green
1250     BLOCK 128,1,128,y+64,32*green+blue     : REMark black to cyan
1260     BLOCK 128,1,0,y+128,blue               : REMark black to blue
1270     BLOCK 128,1,128,y+128,2048*red+32*green: REMark black to
yellow
1280     BLOCK 128,1,0,y+192,nat_col            : REMark
black-grey-white
1290   END FOR y
1300 END DEFine Grad

--
Dilwyn Jones

Reply via email to