|
|||||||||
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.FSColor
public class FSColor
FSColor is used to represent colours.
The FSColor class supports the RGB colour space with an optional alpha channel which is used to specify the transparency of an object. An FSColor object supports 32-bit colours with 8 bits per colour channel.
Attributes | |
---|---|
red | The red channel of the colour, with values in the range 0..255. |
green | The green channel of the colour, with values in the range 0..255. |
blue | The blue channel of the colour, with values in the range 0..255. |
alpha | The alpha channel of the colour, with values in the range 0..255. |
Whether a colour contains transparency information is determined by the context created by the object that contains the colour. For example colours within the FSDefineShape and FSDefineShape2 objects do not contain alpha channel information while those in an FSDefineShape3 object do. To simplify the use of the colours only a single class is provided. The alpha channel can be ignored if not required within the object the colour is defined for. When a FSColor object is encoded or decoded the object notifies the colour objects it contains whether the alpha channel information should also be encoded or decoded. As of Version 5 of the Macromedia Flash (SWF) File Format Specification only the FSPlaceObject2, FSDefineText2 and FSDefineShape3 classes use colours containing an alpha channel.
The class provides a range of constructors to instantiate objects using colour information presented in a variety of formats. To create a colour, specifying values for colour channels in the following order: red, green, blue and optionally alpha:
FSColor red = new FSColor(255, 0, 0); FSColor green = new FSColor(0, 255, 0); FSColor blue = new FSColor(0, 0, 255);
When the alpha channel is not specified it defaults to a value of 255 which defines the colour to be completely opaque. For transparent colours the alpha channel determines how opaque the colour is. 0 represents a fully transparent colour and 255 is fully opaque.
FSColor transparentRed = new FSColor(255, 0, 0, 128); FSColor transparentGreen = new FSColor(0, 255, 0, 128); FSColor transparentBlue = new FSColor(0, 0, 255, 128);
When the alpha channel is not specified it defaults to a value of 255 which defines the colour to be completely opaque. The classes that contain colour objects control whether the value for the alpha channel is encoded. For example FSDefineShape and FSDefineShape2 support opaque colours while FSDefineShape3 supports transparent colours. If only opaque colours are supported then the alpha channel can be ignored when creating and manipulating FSColor objects.
FSColor class represents the colour data types, RGB and RGBA in the Macromedia Flash (SWF) File Format Specification. The colour data structure was available was introduced in Flash 1 and transparent colours were introduced in Flash 3.
Constructor Summary | |
---|---|
FSColor(FSCoder coder)
Construct an FSColor object and initialise it with values decoded from a binary encoded FSColor object. |
|
FSColor(FSColor obj)
Construct an FSColor object and initialise it with value from another FSColor object. |
|
FSColor(int r,
int g,
int b)
Constructs an FSColor object containing red, green and blue channels. |
|
FSColor(int r,
int g,
int b,
int a)
Constructs an FSColor object containing red, green, blue and alpha channels. |
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 |
getAlpha()
Gets the value for the alpha colour channel. |
int |
getBlue()
Gets the value for the blue colour channel. |
int |
getGreen()
Gets the value for the green colour channel. |
int |
getRed()
Gets the value for the red colour channel. |
int |
length(FSCoder coder)
|
void |
setAlpha(int a)
Set the value for the alpha channel. |
void |
setBlue(int b)
Set the value for the blue colour channel. |
void |
setChannels(int r,
int g,
int b)
Set the values for the red, green and blue colour channels. |
void |
setChannels(int r,
int g,
int b,
int a)
Set the values for each of the four colour channels. |
void |
setGreen(int g)
Set the value for the green colour channel. |
void |
setRed(int r)
Set the value for the red colour channel. |
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 FSColor(FSCoder coder)
coder
- an FSCoder object containing an FSColor encoded as binary
data.public FSColor(int r, int g, int b)
r
- value for the red channel, in the range 0..255.g
- value for the green channel, in the range 0..255.b
- value for the blue channel, in the range 0..255.public FSColor(int r, int g, int b, int a)
r
- value for the red channel, in the range 0..255.g
- value for the green channel, in the range 0..255.b
- value for the blue channel, in the range 0..255.a
- value for the alpha channel, in the range 0..255.public FSColor(FSColor obj)
obj
- an FSColor object.Method Detail |
---|
public int getRed()
public int getGreen()
public int getBlue()
public int getAlpha()
public void setRed(int r)
r
- value for the red channel.public void setGreen(int g)
g
- value for the green channel.public void setBlue(int b)
b
- value for the blue channel, in the range 0..255.public void setAlpha(int a)
a
- value for the alpha channel, in the range 0..255.public void setChannels(int r, int g, int b)
r
- value for the red channel, in the range 0..255.g
- value for the green channel, in the range 0..255.b
- value for the blue channel, in the range 0..255.public void setChannels(int r, int g, int b, int a)
r
- value for the red channel, in the range 0..255.g
- value for the green channel, in the range 0..255.b
- value for the blue channel, in the range 0..255.a
- value for the alpha channel, in the range 0..255.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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |