canvas
Class WebSafeColor

java.lang.Object
  |
  +--canvas.BaseColor
        |
        +--canvas.WebSafeColor

public class WebSafeColor
extends BaseColor

This class will hold and return colors that are web-safe. This is a web page that displays all of the 216 web-safe colors. Note that the hex values for the individual components are 00,33,66,99,CC,FF in hexidecimal, and multiples of 51 in base 10. There are 6 gradients of brightness for each pure color, and thus 216 (6^3) total colors. These colors can be flawlessly displayed on a system running in 8-bit mode.


Field Summary
 
Fields inherited from class canvas.BaseColor
color
 
Constructor Summary
WebSafeColor(canvas.AnyColor ac)
          Extracts the color from the AnyColor object and rounds to the neatest web-safe color.
WebSafeColor(Color c)
          Takes the color and rounds to the nearest web-safe color.
WebSafeColor(int n)
          This takes a value from 0 to 215 for the number of the web-safe color.
WebSafeColor(int r, int g, int b)
          Takes the 3 red, green, blue integers (0-255) and rounds to the nearest web-safe values.
 
Method Summary
 Color brighter()
          Returns a brighter version of the held color.
 Color darker()
          Returns a darker version ofthe held color.
 Color desaturate()
          This method will return a less saturated color than the one held.
 Color hueshift(int degrees)
          This will return a color with a different hue than the one held.
 Color saturate()
          This method will return a more saturated color than the one held.
static void SelfTest()
          This method demonstrates the supported methods.
 
Methods inherited from class canvas.BaseColor
getColor, in_range, in_range, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebSafeColor

public WebSafeColor(int r,
                    int g,
                    int b)
Takes the 3 red, green, blue integers (0-255) and rounds to the nearest web-safe values. Values outside the range become 0 or 255, whichever is closest.


WebSafeColor

public WebSafeColor(int n)
This takes a value from 0 to 215 for the number of the web-safe color. This does not take a hex value and pipe it into the Color constructor. In base 6, the least significant digit represents blue, the next most significant digit is green, and the most significant digit represents red. (Base 6 because there are 6 possibilities for each of the color components.)


WebSafeColor

public WebSafeColor(Color c)
Takes the color and rounds to the nearest web-safe color.


WebSafeColor

public WebSafeColor(canvas.AnyColor ac)
Extracts the color from the AnyColor object and rounds to the neatest web-safe color.

Method Detail

brighter

public Color brighter()
Returns a brighter version of the held color. This is acomplished by adding the same number to each of the RGB components and returning a new color with those properties.

Specified by:
brighter in class BaseColor

darker

public Color darker()
Returns a darker version ofthe held color. Does the same thing as brighter(), but instead of adding to the components, this method subtracts.

Specified by:
darker in class BaseColor

saturate

public Color saturate()
This method will return a more saturated color than the one held. There is a possibility that the color returned is the same as the one held because it is not possible to, for example, meaningfully increase the saturation of pure black.

Specified by:
saturate in class BaseColor

desaturate

public Color desaturate()
This method will return a less saturated color than the one held.

Specified by:
desaturate in class BaseColor

hueshift

public Color hueshift(int degrees)
This will return a color with a different hue than the one held. The minimum effective shift is approximately 35 degrees.

Specified by:
hueshift in class BaseColor
Parameters:
degrees - The number of degrees out of 360 to shift the color.

SelfTest

public static void SelfTest()
This method demonstrates the supported methods.