DIGG IT!
4
Comments
Published
Wednesday, February 16, 2005
at
10:34 AM
.
There is a great trick for coloring gradients using Color.setTransform. I am working on a set of Container components for FLOW 2 and needed to color gradients dynamically for panels, dialogs, and windows.&
Ted on Twitter - @AdobeTed
Ted on Adobe Groups
Ted on LinkedIn
Ted on Facebook
Ted at Adobe
Looking at colors this way is very interesting. I keep finding great gradients when the bars are each 15 apart. In almost every case the colors are very warm and balanced.
Cheers,
ted ;)
Aaa .. didn't know that; beautiful! this shd come in handy along the line for something i'm currently working on. thx for sharing :)
cheers,
-- eokyere
I use a similar technique, I like to have a little more control so I make a b/w gradient (or any other grayscale artwork) and use the following to colorize it with 2 colors (one for black, one for white, everything in between is a mix of the two):
function getRGBPct(hex)
{
var clrobj = {};
clrobj.r = hex >> 16;
var temp = hex ^ clrobj.r << 16;
clrobj.g = temp >> 8;
clrobj.b = temp ^ clrobj.g << 8;
for(var i in clrobj)
{
clrobj[i] /= 255;
clrobj[i] *= 100;
}
return clrobj;
}
function colorize(mc,light,dark)
{
var clr = new Color(mc);
transobj = {};
c1 = getRGBPct(light);
c2 = getRGBPct(dark);
transobj.ra = c1.r - c2.r;
transobj.ga = c1.g - c2.g;
transobj.ba = c1.b - c2.b;
transobj.rb = 255 * (c2.r / 100);
transobj.gb = 255 * (c2.g / 100);
transobj.bb = 255 * (c2.b / 100);
clr.setTransform(transobj);
}
Great and useful tips! thanks for sharing, I'm using it in this moment and you can get beautiful gradients : )