Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Gradient colors

Name: Anonymous 2010-05-05 23:24

How would I write a function that would take two colors: (255,0,0), and (0,0,255), a value from 0.0 to 1.0, and have it output the color in between the first two based on that number.  Like, if I ran this function like this:

gradient((255,0,0),(0,0,255),0.5)


it would return


(128,0,128)

Name: Anonymous 2010-05-05 23:30


r = r1*p+r2*(p-1);
g = g1*p+g2*(p-1);
b = b1*p+b2*(p-1);


...isn't it obvious?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List