Color Class | CmykColor Class | Grayscale Class | RgbColor Class | WebColor Class | Gradient Class | Programming with Generator for .NET

Language

Visual Basic

C#

Show All

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

[Visual Basic]
Dim MyCmykColor1 As CmykColor = New CmykColor( 0.5f, 0.3f, 0.6f, 0.0f )
Dim MyCmykColor2 As CmykColor = New CmykColor( 0.3f, 0.5f, 0.6f, 0.2f ) 
MyPage.Elements.Add(New Circle(100, 100, 40, MyCmykColor1, MyCmykColor2))
MyPage.Elements.Add(New Circle(150, 100, 40, CmykColor.Black, CmykColor.Red))
[C#]
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.Elements.Add( new Circle( 100, 100, 40, cmykColor1, cmykColor2 ) );
page.Elements.Add( new Circle( 150, 100, 40, CmykColor.Black, CmykColor.Red ) );

RGB Color

[Visual Basic]
Dim MyRgbColor1 As RgbColor = new RgbColor( 0.5f, 0.3f, 0.6f )
Dim MyRgbColor2 As RgbColor = new RgbColor( 0.3f, 0.5f, 0.2f )
MyPage.Elements.Add(New Circle(100, 100, 40, MyRgbColor1, MyRgbColor2))
MyPage.Elements.Add(New Circle(150, 100, 40, RgbColor.Black, RgbColor.Red))
[C#]
RgbColor rgbColor1 = new RgbColor( 0.5f, 0.3f, 0.6f );
RgbColor rgbColor2 = new RgbColor( 0.3f, 0.5f, 0.2f );
page.Elements.Add( new Circle( 100, 100, 40, rgbColor1, rgbColor2 ) );
page.Elements.Add( new Circle( 150, 100, 40, RgbColor.Black, RgbColor.Red ) );

Web Color

[Visual Basic]
Dim MyWebColor1 As WebColor = new WebColor( "#FF0080" )
Dim MyWebColor2 As WebColor = new WebColor( "aqua" )
MyPage.Elements.Add(New Circle(100, 100, 40, MyWebColor1, MyWebColor2))
[C#]
WebColor webColor1 = new WebColor( "#FF0080" );
WebColor webColor2 = new WebColor( "aqua" );
page.Elements.Add( new Circle( 100, 100, 40, webColor1, webColor2 ) );

Grayscale

[Visual Basic]
Dim MyGrayscale1 As Grayscale = new Grayscale( 0.3f )
Dim MyGrayscale2 As Grayscale = new Grayscale( 0.6f )
MyPage.Elements.Add(New Circle(100, 100, 40, MyGrayscale1, MyGrayscale2))
MyPage.Elements.Add(New Circle(150, 100, 40, Grayscale.White, Grayscale.Black))
[C#]
Grayscale grayscale1 = new Grayscale( 0.3f );
Grayscale grayscale2 = new Grayscale( 0.6f );
page.Elements.Add( new Circle( 100, 100, 40, grayscale1, grayscale2 ) );
page.Elements.Add( new Circle( 150, 100, 40, Grayscale.White, Grayscale.Black ) );

Gradient

[Visual Basic]
Dim gradient1 As Gradient =  New Gradient(0,0,200,200,Grayscale.White,Grayscale.Black) 
Dim gradient2 As Gradient =  New Gradient(50,0,250,200,RgbColor.YellowGreen,RgbColor.DarkMagenta) 
MyPage.Elements.Add(New Circle(100, 100, 40, gradient1, gradient1))
MyPage.Elements.Add(New Circle(150, 100, 40, gradient2, gradient2))
[C#]
Gradient gradient1 = new Gradient( 0, 0, 200, 200, Grayscale.White, Grayscale.Black);
Gradient gradient2 = new Gradient( 50, 0, 250, 200, RgbColor.YellowGreen, RgbColor.DarkMagenta);
page.Elements.Add( new Circle( 100, 100, 40, gradient1, gradient1 ) );
page.Elements.Add( new Circle( 150, 100, 40, gradient2, gradient2 ) );

Spot Color

[Visual Basic]
Dim alternateColor As CmykColor =  New CmykColor(0.2f,0.9f,0.5f,0.2f) 
Dim ink As SpotColorInk =  New SpotColorInk("My Red",alternateColor) 
Dim tint100 As SpotColor =  New SpotColor(1,ink) 
Dim tint50 As SpotColor =  New SpotColor(0.5f,ink) 
MyPage.Elements.Add(New Circle(100, 100, 40, tint50, tint50))
MyPage.Elements.Add(New Circle(150, 100, 40, tint100, tint100))
[C#]
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.Elements.Add( new Circle( 100, 100, 40, tint50, tint50 ) );
page.Elements.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 

Color Class | CmykColor Class | Grayscale Class | RgbColor Class | WebColor Class | Gradient Class | Programming with Generator for .NET