|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.FSTransformObject
com.flagstone.transform.FSColorTransform
public class FSColorTransform
The FSColorTransform is used to change the colour of a shape or button without changing the values in the original definition of the object.
Two types of transformation are supported: Add and Multiply
In Add transformations a value is added to each colour channel:
newRed = red + addRedTerm newGreen = green + addGreenTerm newBlue = blue + addBlueTerm newAlpha = alpha + addAlphaTerm
In Multiply transformations each colour channel is multiplied by a given value:
newRed = red * multiplyRedTerm newGreen = green * multiplyGreenTerm newBlue = blue * multiplyBlueTerm newAlpha = alpha * multiplyAlphaTerm
Add and Multiply transforms may be combined in which case the multiply terms are applied to the colour channel before the add terms.
newRed = (red * multiplyRedTerm) + addRedTerm newGreen = (green * multiplyGreenTerm) + addGreenTerm newBlue = (blue * multiplyBlueTerm) + addBlueTerm newAlpha = (alpha * multiplyAlphaTerm) + addAlphaTerm
For each type of transform the result of the calculation is limited to the range 0..255. If the result is less than 0 or greater than 255 then it is clamped at 0 and 255 respectively.
Attributes | |
---|---|
multiplyRed | The multiply term for the red colour channel. |
multiplyGreen | The multiply term for the green colour channel. |
multiplyBlue | The multiply term for the blue colour channel. |
multiplyAlpha | The optional multiply term for the alpha colour channel. |
addRed | The add term for the red colour channel. |
addGreen | The add term for the green colour channel. |
addBlue | The add term for the blue colour channel. |
addAlpha | The optional add term for the alpha colour channel. |
Not all objects containing a colour transform use the add or multiply terms defined for the alpha channel. The colour objects defined in an FSDefineButton, FSButtonColorTransform or FSPlaceObject object do not use the alpha channel. Transparent colours was introduced in Flash 3. The "parent" object that contains the colour transform controls whether the alpha channel information is encoded or not. Simplifying the alpha channel is not sufficient.
The class provides a range of constructors to support the different colour transformations. To create a colour transform object specify the values for colour channels in the following order: red, green, blue and optionally alpha:
float multRed = 1.5f; float multGreen = 1.5f; float multBlue = 1.5f; float multAlpha = 1.5f; FSColorTransform multiply = new FSColorTransform(multRed, multGreen, multBlue); FSColorTransform multiplyWithAlpha = new FSColorTransform(multRed, multGreen, multBlue, multAlpha);
int addRed = 128; int addGreen = 128; int addBlue = 128; int addAlpha = 128; FSColorTransform add = new FSColorTransform(addRed, addGreen, addBlue); FSColorTransform addWithAlpha = new FSColorTransform(addRed, addGreen, addBlue, addAlpha);
For transforms combining both multiply and add terms:
int addRed = 128; int addGreen = 128; int addBlue = 128; int addAlpha = 128; float multRed = 1.5f; float multGreen = 1.5f; float multBlue = 1.5f; float multAlpha = 1.5f; FSColorTransform combined = new FSColorTransform(multRed, multGreen, multBlue, addRed, addGreen, addBlue); FSColorTransform combinedWithAlpha = new FSColorTransform(multRed, multGreen, multBlue, multAlpha, addRed, addGreen, addBlue, addAlpha);
The FSCoordTransform class represents the CXForm and CXFormWithAlpha data structures from the Macromedia Flash (SWF) File Format Specification. They were introduced in Flash 1 and Flash 3 respectively.
Constructor Summary | |
---|---|
FSColorTransform()
Constructs an FSColorTransform object defining a unity transform. |
|
FSColorTransform(float redTerm,
float greenTerm,
float blueTerm)
Constructs a FSColorTransform object initialised with the specified multiply terms. |
|
FSColorTransform(float redTerm,
float greenTerm,
float blueTerm,
float alphaTerm)
Constructs a FSColorTransform object initialised with the specified multiply terms, including the alpha channel. |
|
FSColorTransform(float multRedTerm,
float multGreenTerm,
float multBlueTerm,
float multAlphaTerm,
int addRedTerm,
int addGreenTerm,
int addBlueTerm,
int addAlphaTerm)
Constructs a FSColorTransform object initialised with the specified addition and multiplication terms, including alpha channel values. |
|
FSColorTransform(float multRedTerm,
float multGreenTerm,
float multBlueTerm,
int addRedTerm,
int addGreenTerm,
int addBlueTerm)
Constructs a FSColorTransform object initialised with the specified addition and multiplication terms. |
|
FSColorTransform(FSCoder coder)
Construct an FSColorTransform object an initialise with the values decoded from an encoded colour transform |
|
FSColorTransform(FSColorTransform obj)
Construct an FSColorTansform object and initialize it using a copy of the values from another colour transform. |
|
FSColorTransform(int redTerm,
int greenTerm,
int blueTerm)
Constructs an FSColorTransform object with the specified add terms. |
|
FSColorTransform(int redTerm,
int greenTerm,
int blueTerm,
int alphaTerm)
Constructs an FSColorTransform object with the specified add terms, including the alpha channel. |
Method Summary | |
---|---|
void |
appendDescription(java.lang.StringBuffer buffer,
int depth)
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. |
void |
decode(FSCoder coder)
|
void |
encode(FSCoder coder)
|
boolean |
equals(java.lang.Object anObject)
Returns true if anObject is equal to this one. |
int |
getAddAlpha()
Gets the value of the add term for the alpha channel. |
int |
getAddBlue()
Gets the value of the add term for the blue channel. |
int |
getAddGreen()
Gets the value of the add term for the green channel. |
int |
getAddRed()
Gets the value of the add term for the red channel. |
float |
getMultiplyAlpha()
Gets the value of the multiply term for the alpha channel. |
float |
getMultiplyBlue()
Gets the value of the multiply term for the blue channel. |
float |
getMultiplyGreen()
Gets the value of the multiply term for the green channel. |
float |
getMultiplyRed()
Gets the value of the multiply term for the red channel. |
boolean |
isUnityTransform(FSCoder coder)
Returns true if the values for the add and multiply terms represent a unity transform - one which will not change the colour of a shape. |
int |
length(FSCoder coder)
|
void |
setAddAlpha(int aNumber)
Sets the value for the addTerm which will be applied to the alpha colour channel. |
void |
setAddBlue(int aNumber)
Sets the value for the addTerm which will be applied to the blue colour channel. |
void |
setAddGreen(int aNumber)
Sets the value for the addTerm which will be applied to the green colour channel. |
void |
setAddRed(int aNumber)
Sets the value for the addTerm which will be applied to the red colour channel. |
void |
setAddTerms(int redTerm,
int greenTerm,
int blueTerm)
Sets the values for the add terms for the red, green and blue colour channels. |
void |
setAddTerms(int redTerm,
int greenTerm,
int blueTerm,
int alphaTerm)
Sets the values for the add terms for each of the colour channels. |
void |
setMultiplyAlpha(float aNumber)
Sets the value for the multiplyTerm which will be applied to the alpha colour channel. |
void |
setMultiplyBlue(float aNumber)
Sets the value for the multiplyTerm which will be applied to the blue colour channel. |
void |
setMultiplyGreen(float aNumber)
Sets the value for the multiplyTerm which will be applied to the green colour channel. |
void |
setMultiplyRed(float aNumber)
Sets the value for the multiplyTerm which will be applied to the red colour channel. |
void |
setMultiplyTerms(float redTerm,
float greenTerm,
float blueTerm)
Sets the values for the multiply terms for the red, green and blue colour channels |
void |
setMultiplyTerms(float redTerm,
float greenTerm,
float blueTerm,
float alphaTerm)
Sets the values for the multiply terms for each of the colour channels |
Methods inherited from class com.flagstone.transform.FSTransformObject |
---|
clone, name, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FSColorTransform(FSCoder coder)
coder
- an FSCoder object containing the encoded colour transform.public FSColorTransform()
public FSColorTransform(int redTerm, int greenTerm, int blueTerm)
newRed = red + addRedTerm newGreen = green + addGreenTerm newBlue = blue + addBlueTermThe add term value for the alpha channel defaults to 0 so if the transform is added to an object that uses alpha channel information then the alpha channel will remain unchanged. In the Flash Player the value assigned to the respective colour channel is clamped to the range 0..255.
redTerm
- value to add to the red colour channel.greenTerm
- value to add to the green colour channel.blueTerm
- value to add to the blue colour channel.public FSColorTransform(int redTerm, int greenTerm, int blueTerm, int alphaTerm)
newRed = red + addRedTerm newGreen = green + addGreenTerm newBlue = blue + addBlueTerm newAlpha = alpha + addAlphaTermIn the Flash Player the value assigned to the respective colour channel is clamped to the range 0..255.
redTerm
- value to add to the red colour channel.greenTerm
- value to add to the green colour channel.blueTerm
- value to add to the blue colour channel.alphaTerm
- value to add to the alpha colour channel.public FSColorTransform(float redTerm, float greenTerm, float blueTerm)
newRed = red * multiplyRedTerm newGreen = green * multiplyGreenTerm newBlue = blue * multiplyBlueTermThe multiply term value for the alpha channel defaults to 1.0 so if the transform is added to an object that uses alpha channel information then the alpha channel will remain unchanged. In the Flash Player the value assigned to the respective colour channel is clamped to the range 0..255.
redTerm
- value to multiply the red colour channel by.greenTerm
- value to multiply the green colour channel by.blueTerm
- value to multiply the blue colour channel by.public FSColorTransform(float redTerm, float greenTerm, float blueTerm, float alphaTerm)
newRed = red * multiplyRedTerm newGreen = green * multiplyGreenTerm newBlue = blue * multiplyBlueTerm newAlpha = alpha * multiplyAlphaTermIn the Flash Player the value assigned to the respective colour channel is clamped to the range 0..255.
redTerm
- value to multiply the red colour channel by.greenTerm
- value to multiply the green colour channel by.blueTerm
- value to multiply the blue colour channel by.alphaTerm
- value to multiply the alpha colour channel by.public FSColorTransform(float multRedTerm, float multGreenTerm, float multBlueTerm, int addRedTerm, int addGreenTerm, int addBlueTerm)
newRed = (red * multiplyRedTerm) + addRedTerm newGreen = (green * multiplyGreenTerm) + addGreenTerm newBlue = (blue * multiplyBlueTerm) + addBlueTermThe multiply and add terms for the alpha channel default to 1.0 and 0 respectively so for objects that use the alpha channel information then the alpha channel will remain unchanged. In the Flash Player the value assigned to the respective colour channel is clamped to the range 0..255.
multRedTerm
- value to multiply the red colour channel by.multGreenTerm
- value to multiply the green colour channel by.multBlueTerm
- value to multiply the blue colour channel by.addRedTerm
- value to add to the red colour channel.addGreenTerm
- value to add to the green colour channel.addBlueTerm
- value to add to the blue colour channel.public FSColorTransform(float multRedTerm, float multGreenTerm, float multBlueTerm, float multAlphaTerm, int addRedTerm, int addGreenTerm, int addBlueTerm, int addAlphaTerm)
newRed = (red * multiplyRedTerm) + addRedTerm newGreen = (green * multiplyGreenTerm) + addGreenTerm newBlue = (blue * multiplyBlueTerm) + addBlueTerm newAlpha = (alpha * multiplyAlphaTerm) + addAlphaTermIn the Flash Player the value assigned to the respective colour channel is clamped to the range 0..255.
multRedTerm
- value to multiply the red colour channel by.multGreenTerm
- value to multiply the green colour channel by.multBlueTerm
- value to multiply the blue colour channel by.multAlphaTerm
- value to multiply the alpha colour channel by.addRedTerm
- value to add to the red colour channel.addGreenTerm
- value to add to the green colour channel.addBlueTerm
- value to add to the blue colour channel.addAlphaTerm
- value to add to the alpha colour channel.public FSColorTransform(FSColorTransform obj)
obj
- a colour transform.Method Detail |
---|
public float getMultiplyRed()
public float getMultiplyGreen()
public float getMultiplyBlue()
public float getMultiplyAlpha()
public int getAddRed()
public int getAddGreen()
public int getAddBlue()
public int getAddAlpha()
public void setMultiplyRed(float aNumber)
aNumber
- the value to be multiplied with the red colour channel's
value.public void setMultiplyGreen(float aNumber)
aNumber
- the value to be multiplied with the green colour channel's
value.public void setMultiplyBlue(float aNumber)
aNumber
- the value to be multiplied with the blue colour channel's
value.public void setMultiplyAlpha(float aNumber)
aNumber
- the value to be multiplied with the alpha colour channel's
value.public void setMultiplyTerms(float redTerm, float greenTerm, float blueTerm)
redTerm
- value to multiply the red colour channel by.greenTerm
- value to multiply the green colour channel by.blueTerm
- value to multiply the blue colour channel by.public void setMultiplyTerms(float redTerm, float greenTerm, float blueTerm, float alphaTerm)
redTerm
- value to multiply the red colour channel by.greenTerm
- value to multiply the green colour channel by.blueTerm
- value to multiply the blue colour channel by.alphaTerm
- value to multiply the alpha colour channel by.public void setAddRed(int aNumber)
aNumber
- the value to be added to the red colour channel's value.public void setAddGreen(int aNumber)
aNumber
- the value to be added to the green colour channel's value.public void setAddBlue(int aNumber)
aNumber
- the value to be added to the blue colour channel's value.public void setAddAlpha(int aNumber)
aNumber
- the value to be added to the alpha colour channel's value.public void setAddTerms(int redTerm, int greenTerm, int blueTerm, int alphaTerm)
redTerm
- value to add to the red colour channel.greenTerm
- value to add to the green colour channel.blueTerm
- value to add to the blue colour channel.alphaTerm
- value to add to the alpha colour channel.public void setAddTerms(int redTerm, int greenTerm, int blueTerm)
redTerm
- value to add to the red colour channel.greenTerm
- value to add to the green colour channel.blueTerm
- value to add to the blue colour channel.public boolean equals(java.lang.Object anObject)
equals
in class FSTransformObject
public void appendDescription(java.lang.StringBuffer buffer, int depth)
FSTransformObject
appendDescription
in class FSTransformObject
buffer
- a StringBuffer to which the description of each object is
appended.depth
- the maximum level of nesting up to which objects will be
displayed.public int length(FSCoder coder)
length
in class FSTransformObject
public void encode(FSCoder coder)
encode
in class FSTransformObject
public void decode(FSCoder coder)
decode
in class FSTransformObject
public boolean isUnityTransform(FSCoder coder)
coder
- the FSCoder used to encoded the transform.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |