DirectX Media for Animation Java Reference Previous
Previous
Classes
Classes
Index
Index
Next
Next

ColorBvr Class

Methods , Fields

public class ColorBvr extends Behavior {
    // Fields
    public static ColorBvr black;
    public static ColorBvr blue;
    public static ColorBvr cyan;
    public static ColorBvr green;
    public static ColorBvr magenta;
    public static ColorBvr red;
    public static ColorBvr white;
    public static ColorBvr yellow;
        
    // Methods
    public NumberBvr getBlue();
    public NumberBvr getGreen();
    public NumberBvr getHue();
    public NumberBvr getLightness();
    public NumberBvr getRed();
    public NumberBvr getSaturation();
    
    public static ColorBvr colorHsl(NumberBvr h, NumberBvr s, NumberBvr l);
    public static ColorBvr colorRgb(NumberBvr r, NumberBvr g, NumberBvr b);
    public static ColorBvr newUninitBvr();
            
}

A ColorBvr is an object that represents a color behavior. At any given time, the value of the behavior is a color value that represents a specific color. Each color value consists of a combination of component values that specify either red, green and blue intensity or hue, saturation, and lightness.

Because component values are number behaviors (NumberBvr objects), the value of the color behavior may change over time as the number behaviors change.

For more information about behaviors, see the Behavior class.


Methods


getBlue

public NumberBvr getBlue();

Creates a number behavior that represents the value of the blue component of the corresponding color behavior.

Return Value:

Returns the NumberBvr object.

See Also: getRed, getGreen


getGreen

public NumberBvr getGreen();

Creates a number behavior that represents the value of the green component of the corresponding color behavior.

Return Value:

Returns the NumberBvr object.

See Also: getRed, getBlue


getHue

public NumberBvr getHue();

Creates a number behavior that represents the value of the hue of the corresponding color behavior.

Return Value:

Returns the NumberBvr object.

See Also: getLightness, getSaturation


getLightness

public NumberBvr getLightness();

Creates a number behavior that represents the value of the lightness of the corresponding color behavior.

Return Value:

Returns the NumberBvr object.

See Also: getHue, getSaturation


getRed

public NumberBvr getRed();

Creates a number behavior that represents the value of the red component of the corresponding color behavior.

Return Value:

Returns the NumberBvr object.

See Also: getGreen, getBlue


getSaturation

public NumberBvr getSaturation();

Creates a number behavior that represents the value of the saturation of the corresponding color behavior.

Return Value:

Returns the NumberBvr object.

See Also: getHue, getLightness


colorHsl

public static ColorBvr colorHsl(NumberBvr h, NumberBvr s, NumberBvr l);

Creates a color behavior that represents a color given by hue, saturation, and lightness values. The behavior's value at any given time depends on the values of h, s, and l. The following example creates a color whose hue varies with time, but whose saturation and lightness values are constant:

//vary the hue over time
ColorBvr animCol = colorHsl(localTime, toBvr(0.5), toBvr(0.5));

Return Value:

Returns the ColorBvr object.

ParameterDescription
h A NumberBvr object specifying the hue or base color. 0.0 is red, 0.33 is green, and 0.67 is blue. This number is considered "modulo 1," which means, for example, that the numbers 1.67, -12.67, and 0.67 are all considered to be 0.67.
s A NumberBvr object specifying saturation or intensity of the hue. If saturation is 0.0, the color produced is gray regardless of the hue value.
l A NumberBvr object specifying lightness or amount of white in the color. If lightness is 1.0, the color produced is white regardless of the hue and saturation values. Similarly, if lightness is 0.0, the color is black.

Remarks:

Hue, saturation, and lightness values can range from 0.0 to 1.0. If the corresponding number behavior has a value outside this range, the integer part of the value is discarded and only the fractional part is used.

See Also: colorRgb


colorRgb

public static ColorBvr colorRgb(NumberBvr r, NumberBvr g, NumberBvr b);

Creates a color behavior that represents a color given by red, green, and blue intensity values. The behavior's value at any given time depends on the values of r, g, and b. The following example creates a color behavior whose red component varies from 0 to 1:

//Create a sawtooth wave that goes repetitively from 0 to 1
//Do this by taking the modulus of localTime and 1
NumberBvr sawtooth = mod(localTime, toBvr(1));
//Now create the RGB color, making red = to the value of sawtooth
ColorBvr col = colorRGB(sawtooth, toBvr(0), toBvr(0));

Return Value:

Returns the ColorBvr object.

ParameterDescription
r, g, and b The NumberBvr objects specifying the red, green, and blue values, respectively. The value of each specifies that color's intensity, with 0.0 for no color and 1.0 for the highest possible intensity.

Remarks:

Intensity values can range from 0.0 to 1.0. If the corresponding number behavior has a value outside this range, the integer part of the value is discarded and only the fractional part is used.

See Also: colorHsl


newUninitBvr

public static ColorBvr newUninitBvr();

This method allows you to refer to a color behavior before that behavior has been defined. With this method you can create the behavior and use it in the definition of other behaviors, but not actually define its contents until some later point. (This is accomplished with the init method, which is available on all behaviors.) The system generates a run-time error if you initialize a non-uninitialized behavior, initialize an uninitialized behavior that has already been initialized, or run an initialized behavior that has not yet been initialized.


Fields

black
A color behavior (ColorBvr object) that is always black. Its red, green, and blue intensity values are 0.0,0.0,0.0.
blue
A color behavior (ColorBvr object) that is always blue. Its red, green, and blue intensity values are 0.0,0.0,1.0.
cyan
A color behavior (ColorBvr object) that is always cyan. Its red, green, and blue intensity values are 0.0,1.0,1.0.
green
A color behavior (ColorBvr object) that is always green. Its red, green, and blue intensity values are 0.0,1.0,0.0.
magenta
A color behavior (ColorBvr object) that is always magenta. Its red, green, and blue intensity values are 1.0,0.0,1.0.
red
A color behavior (ColorBvr object) that is always red. Its red, green, and blue intensity values are 1.0,0.0,0.0.
white
A color behavior (ColorBvr object) that is always white. Its red, green, and blue intensity values are 1.0,1.0,1.0.
yellow
A color behavior (ColorBvr object) that is always yellow. Its red, green, and blue intensity values are 1.0,1.0,0.0.


Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.