org.gwoptics.graphics
Class GWColour

java.lang.Object
  extended by org.gwoptics.graphics.GWColour

public final class GWColour
extends java.lang.Object

Simple class that encapsulates the 4 colour components alpha, red, green and blue. It should be noted that the values should be stored as normalised floats between 0.0f and 1.0f not 0 and 255. Contains several functions to relate ARGB as a 32-bit integer using bit shifting.

Since:
0.1.1
Author:
Daniel Brown 12/6/09

Field Summary
 float A
           
 float B
           
 float G
           
 float R
           
 
Constructor Summary
GWColour()
          Default GWColour constructor assign a black colour with full opactiy
GWColour(float Red, float Green, float Blue)
          GWColour constructor allowing user defined RGB values.
GWColour(float Alpha, float Red, float Green, float Blue)
          Colour constructor allowing user defined RGB values.
GWColour(int colour)
          GWColour constructor accepting an integer representing the A, R, G and B components of a colour
GWColour(int Red, int Green, int Blue)
          Colour constructor allowing user defined RGB values.
GWColour(int alpha, int Red, int Green, int Blue)
           
 
Method Summary
static GWColour add(GWColour c1, GWColour c2)
          Adds 2 colours
static int convertARGBToInt(byte A, byte R, byte G, byte B)
          A static function used to convert 0 to 255 values or ARGB into an integer.
static int convertColourToInt(GWColour c)
          Static function to convert a Colour object into an integer.
static GWColour convertIntToColour(int iC)
          Static function to convert an integer into a Colour object.
static int convertRGBToInt(byte R, byte G, byte B)
          A static function used to convert 0 to 255 values of RGB into an integer.
static int getAlphaRGB(GWColour c)
          Returns int version of a Colour but applies, alpha to each channel
static GWColour multiply(GWColour c1, GWColour c2)
          Multiplies 2 colours
 int toAlphaInt()
          Converts Colour object into an integer.
 int toInt()
          Converts Colour object into an integer.
 java.lang.String toString()
          Returns a string in the format (R,G,B).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

A

public float A

R

public float R

G

public float G

B

public float B
Constructor Detail

GWColour

public GWColour()
Default GWColour constructor assign a black colour with full opactiy


GWColour

public GWColour(int colour)
GWColour constructor accepting an integer representing the A, R, G and B components of a colour


GWColour

public GWColour(float Red,
                float Green,
                float Blue)
GWColour constructor allowing user defined RGB values. Values should be between 0.0f and 1.0f.

Parameters:
Red - Red value between 0.0f and 1.0f.
Green - Green value between 0.0f and 1.0f.
Blue - Blue value between 0.0f and 1.0f.

GWColour

public GWColour(float Alpha,
                float Red,
                float Green,
                float Blue)
Colour constructor allowing user defined RGB values. Values should be between 0.0f and 1.0f.

Parameters:
Alpha - Alpha value between 0.0f and 1.0f.
Red - Red value between 0.0f and 1.0f.
Green - Green value between 0.0f and 1.0f.
Blue - Blue value between 0.0f and 1.0f.

GWColour

public GWColour(int Red,
                int Green,
                int Blue)
Colour constructor allowing user defined RGB values. Values should be between 0 and 255.

Parameters:
Red - Red value between 0 and 255.
Green - Green value between 0 and 255.
Blue - Blue value between 0 and 255.

GWColour

public GWColour(int alpha,
                int Red,
                int Green,
                int Blue)
Method Detail

toString

public java.lang.String toString()
Returns a string in the format (R,G,B).

Overrides:
toString in class java.lang.Object

convertRGBToInt

public static int convertRGBToInt(byte R,
                                  byte G,
                                  byte B)
A static function used to convert 0 to 255 values of RGB into an integer. Alpha is assumed to be 255.

Parameters:
R - Red value between 0 and 255
G - Green value between 0 and 255
B - Blue value between 0 and 255
Returns:
Integer with 4 bytes in the form ARGB

convertARGBToInt

public static int convertARGBToInt(byte A,
                                   byte R,
                                   byte G,
                                   byte B)
A static function used to convert 0 to 255 values or ARGB into an integer.

Parameters:
A - Alpha value between 0 and 255
R - Red value between 0 and 255
G - Green value between 0 and 255
B - Blue value between 0 and 255
Returns:
Integer with 4 bytes in the form ARGB

convertColourToInt

public static int convertColourToInt(GWColour c)
Static function to convert a Colour object into an integer.

Parameters:
c - Colour object
Returns:
Integer with 4 bytes in the form ARGB

convertIntToColour

public static GWColour convertIntToColour(int iC)
Static function to convert an integer into a Colour object.

Parameters:
iC - Integer to convert
Returns:
Colour object relating to integer

add

public static GWColour add(GWColour c1,
                           GWColour c2)
Adds 2 colours


multiply

public static GWColour multiply(GWColour c1,
                                GWColour c2)
Multiplies 2 colours


getAlphaRGB

public static int getAlphaRGB(GWColour c)
Returns int version of a Colour but applies, alpha to each channel


toInt

public int toInt()
Converts Colour object into an integer.


toAlphaInt

public int toAlphaInt()
Converts Colour object into an integer.



processing library gwoptics by Daniel Brown and Andreas Freise. (c) 2009 onwards