Blending Colors

BlitzMax Forums/BlitzMax Beginners Area/Blending Colors

Will(Posted 2005) [#1]
Can I draw a line that blends between two colors? Like, its red at one point, and blends evenly to blue at another?


Erroneouss(Posted 2005) [#2]
nevermind


ImaginaryHuman(Posted 2005) [#3]
You can use direct OpenGL to do it since you can specify a `vertex` (end point) color for every point (ie a color for the start of the line, and a color for the end of the line). It would be something like:

glShadeModel(GL_SMOOTH) ' make sure gauraud shading is on
glBegin(GL_LINES) ' begin defining some lines
glColor3b($FF,$FF,$FF) ' set the current end-point color to white
glVertex2i(50,50) ' define the first end-point/vertex
glColor3b($FF,$00,$00) ' set the current end-point color to red
glVertex2i(200,100) ' define the second end-point to complete the line
glEnd

This should draw a line that starts with white and blends gradually into red, for example. Also feel free to use glColor4b and include an extra ALPHA parameter - the line can fade out gradually.

Just beware that if you start adjusting OpenGL settings such as setting colors and switching the shade model, you might interfering with Max2D's assumptions.


Will(Posted 2005) [#4]
Thanks allot - also, does glVertex2i(50,50) correspond to pixel position 50, 50 ?


ImaginaryHuman(Posted 2005) [#5]
Yes.