Didn't catch if someone already replied, but might I suggest: If you can plot points (new to GTK, don't ask me how), just get the RGB color values (or KKKKRRRRGGGGBBBB - which i think is the format gtk uses : k=black level, r=red level g=green level and b=blue level).. Call "StartR" "StartG" "StartB" the starting color's red, green and blue components which you should be able to extract from the above format somehow. Then have "EndR" "EndG" and "EndB" for the ending colors. Then have a dynamic "CurrentR" "CurrentG" and "CurrentB" color, and an "IncrementR" "IncrementG" and "IncrementB". Next, get the length (or height, depending on how you're doing it) of the area you're putting the gradient on (# of pixels, that is) and call it "size". Assign "IncrementR"="(EndR-StartR)/size (or StartR-EndR depending on which is "bigger", in all cases), then "IncrementG"=(EndG-StartG)/size, then "IncrementB"=(EndB-StartB)/size. Set CurrentR CurrentG and CurrentB initially to the appropriate Start values. Let's say hypothetically you have a box that is 100 px x 100 px, and you're putting the gradient from top to bottom. Draw the top line (0,0 to 100,0) with CurrentR CurrentB and CurrentG as the color. Then increment each of those by the appropriate increment value. Draw the next line, increment the color, next line, increment, .... you get the idea (I hope)... -Rob
|