IColorable
Last updated
Was this helpful?
Last updated
Was this helpful?
The IColorable interface defines properties for interacting with an object which can have its color dynamically modified and which can specify how it "blends" with objects behind it. Common objects which implement the IColorable interface include the and object.
can be used to change the color of a IColorable at runtime. require two pieces of information: the color specified by three values (Red, Green, and Blue) and the operation to perform with the specified color.
The default for most IColorables (like ) is .None. Unless the is changed, the Red, Green, and Blue properties will have no effect on way the IColorable is rendered. The default for is .
The Red, Green, and Blue properties provide access to the components of the color which is used to change the IColorable's color. The property specifies how to modify the color.
Color values range between 0 and 1 and are all set to 0 by default.
The exception is the object. The Text object has its Red, Green, and Blue color values set to 1 so that the text appears as white. Furthermore, the defaults to .Modulate for the object.
The following code will create five Sprites, each with a different .
Unlike the color components, modifying the Alpha value will affect the appearance of an IColorable with its default BlendOperation.
BlendOperations control how IColorables blend with objects behind them. The following code shows two rows of Sprites - the first with the default BlendOperation.Regular and the second with BlendOperation.Add;
The AlphaRate property modifies the Alpha property similar to the ColorRate properties. AlphaRate can be used to fade an IColorable in and out.
Most IColorables are created with an Alpha value of 1. This generally represents full opacity. AlphaRate can change this value over time. A positive AlphaRate value will increase the Alpha property over time, and a negative AlphaRate value will decrease the Alpha property over time. The formula (which is generally applied automatically for managed objects) is:
Therefore, a fully opaque object with an AlphaRate of -1 will disappear in 1 second. Increasing the absolute value of the AlphaRate makes the object disappear faster. That is, an AlphaRate of -2 (twice as large in absolute value terms) will make an object disappear after .5 seconds (half as long). The formula is:
Therefore, we can see that an AlphaRate value of -2 will cause an object to disappear in
For more information on specific , see the .
Color rates are values which change the Red, Green, and Blue values over time. The rates, just like all velocity values, indicate units changed per second. The following code creates 80 Sprites and randomly varies their colors using a .
The Alpha and BlendOperation properties are related just as the components of color and properties. The Alpha property is used to control the transparency of an IColorable.
Did this article leave any questions unanswered? Post any question in our for a rapid response.