Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

color.setTransform(??????) 1

Status
Not open for further replies.

p3t3

Programmer
Aug 21, 2002
46
GB
code...

myColor = new Color(this.geezaBody);
myColorTransform = new Object();
// Set the values for myColorTransform
myColorTransform = { ra: '30', rb: '0', ga: '30', gb: '0', ba: '30', bb: '0', aa: '100', ab: '0'};
myColor.setTransform(myColorTransform);

fine, makes an object pale. But ive had to get these values with lots of trying, can someone please explain what the terms 'ammount' and 'offset' relate to each other, as defined in the reference (
•ra is the percentage for the red component (-100 to 100).
•rb is the offset for the red component (-255 to 255).
etc, etc

)

for example if i have a shape with fill colour 0xff0000 (full red) how do the ra, rb values effect this? And how would one cancel out a given transform, i.e what is its opposite?
 
The final value of a color in a transformed clip is determined by combining its original (author-time) color component values with the transformation percentages and offsets set through the Color object, as follows:
R = originalRedValue * (redTransformPercentage/100) + redTransformOffset
G = originalGreenValue * (greenTransformPercentage/100) + greenTransformOffset
B = originalBlueValue * (blueTransformPercentage/100) + redTransformOffset
A = originalAlphaValue * (alphaTransformPercentage/100) + alphaTransformOffset
 
'ra' works as a percentage value so if you alter the 'ra' setting to 75 the red values in your clip will be reduced to 75% of their original value. The default is 100% (negative values strike me as weird here as you can't have less than 0% of a colour technically be WTF... makes a difference in the math of the equation somewhere else apparently)

'rb' offset works without a percentage - if you create an offset of -50 the red value in your clip is reduced by 50, not by 50%. This defaults to 0.
 
thanks both of you.

I have to say that, although powerful, this function is very confusing. As far as I can tell with my experiments, the offset and the percentage are both taken into account, and as you say, wangbar, the fact you can give negative percentages is, err, strange.

I am still having a lot trouble figuring out how to reverse a given transformation. i.e apply any transformation, then apply a second to return to the state before...
 
You can getTransform() as well as setTransform() so you could get the current settings, store them in an object, apply the new transformation, then reset to the stored values - I use this for rollovers etc all the time and it works really well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top