|
|
|
#1 |
|
Member
Join Date: Jan 2001
Posts: 83
|
color blending prototype
I have two color objects that I stored using getTransform().
I set the color of the movieclip to the first color Object. When I click on the movieclip, I want it to slowly blend to the color of the second color object. How do I do that? |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
I would do this using a single color object, which you modify dynamically.
Let's say you have two r,g,b values: r1,g1,b1 // original color r2,g2,b2 // destination color You would start by setting the color object to r1,g1,b1. Then over time, you would tween it to r2,g2,b2. During the course of the animation, the value of t (for time) is set to go from 0 to 1. Then: r - t*r2 + (1-t)*r1; g - t*g2 + (1-t)*g1; b - t*b2 + (1-t)*b1; This is a basic linear-interpolation forumula. Notice that when t is near zero, the color is very close to r1,g1,b1 but when t is near one, the color is very close to r2,g2,b2. Here's a script which uses this technique to transform a movieclip from red to green over 4 seconds.
For more subtle tints, you can use setTransform instead of setRGB, but the method of interpolation is the same - for each element in the transform array whcih changes, interpolate it using x = t*x2 + (1-t)*x1; Last edited by jbum; 10-07-2004 at 03:43 PM. |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|