CmykColor Class | Color Class | Grayscale Class | RgbColor Class | WebColor Class | Gradient Class |  Programming With Generator for Java

Welcome > Generator >Programming > Colors

Colors are handled by a Color base class. Colors can be of the following types:

These colors can be used with many of the Page Element objects. RGB and Web colors can be used with the Outline and Bookmark Objects.

Examples for creating color objects:

CMYK Color

[Java]
    CmykColor cmykColor1 = new CmykColor( 0.5f, 0.3f, 0.6f, 0.0f );
    CmykColor cmykColor2 = new CmykColor( 0.3f, 0.5f, 0.6f, 0.2f );
    page.getElements().add( new Circle( 100, 100, 40, cmykColor1, cmykColor2 ) );
    page.getElements().add( new Circle( 150, 100, 40, CmykColor.getBlack(), CmykColor.getRed() ) );

RGB Color

[Java]
    RgbColor rgbColor1 = new RgbColor( 0.5f, 0.3f, 0.6f );
    RgbColor rgbColor2 = new RgbColor( 0.3f, 0.5f, 0.2f );
    page.getElements().add( new Circle( 100, 100, 40, rgbColor1, rgbColor2 ) );
    page.getElements().add( new Circle( 150, 100, 40, RgbColor.getBlack(), RgbColor.getRed() ) );

Web Color

[Java]
    WebColor webColor1 = new WebColor( "#FF0080" );
    WebColor webColor2 = new WebColor( "aqua" );
    page.getElements().add( new Circle( 100, 100, 40, webColor1, webColor2 ) );

Grayscale

[Java]
    Grayscale grayscale1 = new Grayscale( 0.3f );
    Grayscale grayscale2 = new Grayscale( 0.6f );
    page.getElements().add( new Circle( 100, 100, 40, grayscale1, grayscale2 ) );
    page.getElements().add( new Circle( 150, 100, 40, Grayscale.getWhite(), Grayscale.getBlack() ) );

Gradient

[Java]
    Gradient gradient1 = new Gradient( 0, 0, 200, 200, Grayscale.getWhite(), Grayscale.getBlack());
    Gradient gradient2 = new Gradient( 50, 0, 250, 200, RgbColor.getYellowGreen(), RgbColor.getDarkMagenta());
    page.getElements().add( new Circle( 100, 100, 40, gradient1, gradient1 ) );
    page.getElements().add( new Circle( 150, 100, 40, gradient2, gradient2 ) );

Spot Color

[Java]
    CmykColor alternateColor = new CmykColor( 0.2f, 0.9f, 0.5f, 0.2f );
    SpotColorInk ink = new SpotColorInk( "My Red", alternateColor );
    SpotColor tint100 = new SpotColor( 1, ink );
    SpotColor tint50 = new SpotColor( 0.5f, ink );
    page.getElements().add( new Circle( 100, 100, 40, tint50, tint50 ) );
    page.getElements().add( new Circle( 150, 100, 40, tint100, tint100 ) );

Predefined Colors

The color class includes over 140 predefined colors accessed through static property of the Color class by color name. These names correspond with the colors commonly used in web development. These can also be specified by name in the constructor of the WebColor class or from within an FormattedTextArea

 

See Also 

CmykColor Class | Color Class | Grayscale Class | RgbColor Class | WebColor Class | Gradient Class |  Programming With Generator for Java