scenic
Class ScenicColor

java.lang.Object
  extended by scenic.ScenicColor

public class ScenicColor
extends java.lang.Object

This class defines a color that consists of red, green, blue and alpha components. Each component is a single precision floating point number which ranges from 0 to 1. By default, alpha component 1 means fully opaque and 0 fully transparent. Scenic uses premultiplied alpha ie. the red, green and blue channels are not multiplied with the alpha value when the color is displayed. The range of the color values is not limited. Currently, however, values outside 0 - 1 are not supported by the renderer.


Field Summary
 float alpha
           
 float blue
           
 float green
           
 float red
           
 
Constructor Summary
ScenicColor()
          Default constructor.
ScenicColor(java.awt.Color color)
           
ScenicColor(float luminance)
          Creates a grey with the given luminance.
ScenicColor(float red, float green, float blue)
          Creates a color with the given red, green and blue values.
ScenicColor(float red, float green, float blue, float alpha)
          Creates a color with the given red, green, blue and alpha values.
 
Method Summary
static ScenicColor byteColor(int red, int green, int blue)
          Creates a color using 8-bit component values in the range 0-255.
static ScenicColor byteColor(int red, int green, int blue, int alpha)
          Creates a color using 8-bit component values in the range 0-255.
static float clamp(float a)
          Clamps the given value to the range [0, 1].
static ScenicColor interpolate(ScenicColor a, ScenicColor b, float v)
          Interpolates between the given colors.
 ScenicColor multiply(float m)
          Returns a color multiplied with the given value.
 ScenicColor multiplyByAlpha()
          Returns a color multiplied by the alpha channel.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

red

public float red

green

public float green

blue

public float blue

alpha

public float alpha
Constructor Detail

ScenicColor

public ScenicColor()
Default constructor. All components are set to 0.


ScenicColor

public ScenicColor(float luminance)
Creates a grey with the given luminance. Red, green and blue channels are set to the luminance value. Alpha is set to 1.

Parameters:
luminance - the luminance value.

ScenicColor

public ScenicColor(float red,
                   float green,
                   float blue)
Creates a color with the given red, green and blue values. Alpha is set to 1.


ScenicColor

public ScenicColor(float red,
                   float green,
                   float blue,
                   float alpha)
Creates a color with the given red, green, blue and alpha values.


ScenicColor

public ScenicColor(java.awt.Color color)
Method Detail

byteColor

public static ScenicColor byteColor(int red,
                                    int green,
                                    int blue)
Creates a color using 8-bit component values in the range 0-255.


byteColor

public static ScenicColor byteColor(int red,
                                    int green,
                                    int blue,
                                    int alpha)
Creates a color using 8-bit component values in the range 0-255.


clamp

public static float clamp(float a)
Clamps the given value to the range [0, 1].

Parameters:
a - the value to be clamped.
Returns:
the clamped value.

multiply

public ScenicColor multiply(float m)
Returns a color multiplied with the given value. Red, green and blue channels are multiplied with the given value. Alpha channel is left unchanged.

Parameters:
m - the value used for multiplication.
Returns:
the multiplied color.

multiplyByAlpha

public ScenicColor multiplyByAlpha()
Returns a color multiplied by the alpha channel. Red, green and blue channels are multiplied with the alpha channel. The alpha channel is left unchanged.

Returns:
the color multiplied by alpha.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

interpolate

public static ScenicColor interpolate(ScenicColor a,
                                      ScenicColor b,
                                      float v)
Interpolates between the given colors. The v parameter should be in the range [0, 1].

Parameters:
a - the first color to be interpolated.
b - the second color to be interpolated.
v - selects the position between the colors.
Returns:
the interpolated color.