Colors
The Color base class represents colors in DynamicPDF Core Suite. Colors can be of the following types:
- CMYK - Specified with C, M, Y, and K color values
- RGB - Specified with R, G, and B color values
- Web - Specified with the Web color format (i.e. "#FF0080" or "aqua")
- Grayscale - Specified as a level of gray
- Gradient - Specified with two colors of the same type
- Auto Gradient - Specified with two colors of the same type
- Spot Color - Specifies a tint (shading) of a spot color ink
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.
The following examples illustrate using colors.
CMYK Color
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 ));
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))
RGB Color
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 ) );
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))
Web Color
WebColor webColor1 = new WebColor( "#FF0080" );
WebColor webColor2 = new WebColor( "aqua" );
page.Elements.Add( new Circle( 100, 100, 40, webColor1, webColor2 ) );
Dim MyWebColor1 As WebColor = new WebColor( "#FF0080" )
Dim MyWebColor2 As WebColor = new WebColor( "aqua" )
MyPage.Elements.Add(New Circle(100, 100, 40, MyWebColor1, MyWebColor2))
Grayscale
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 ) );
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))
Gradient
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 ) );
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))
Auto Gradient
AutoGradient autogradient1 = new AutoGradient(90.0f, CmykColor.Blue, CmykColor.Red);
AutoGradient autogradient2 = new AutoGradient(90.0f, CmykColor.Red, CmykColor.Blue);
page.Elements.Add( new Circle( 100, 100, 40, autogradient1, autogradient1 ) );
page.Elements.Add( new Circle( 150, 100, 40, autogradient2, autogradient2 ) );
Dim MyAutoGradient1 As AutoGradient = New AutoGradient(90.0F, CmykColor.Blue, CmykColor.Red)
Dim MyAutoGradient2 As AutoGradient = New AutoGradient(90.0F, CmykColor.Red, CmykColor.Blue)
MyPage.Elements.Add(New Circle(100, 100, 40, MyAutoGradient1, MyAutoGradient1))
MyPage.Elements.Add(New Circle(150, 100, 40, MyAutoGradient2, MyAutoGradient2))
Spot Color
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 ) );
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))
Predefined Colors
The Color class includes over 140 predefined colors accessed through the 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 a FormattedTextArea.