Colors#
Define colors#
With the method
you can define a color for later usage in the PDF document. The color object is taken from the backend:
type Color struct {
Space Space
Basecolor string
SpotcolorID int
C float64
M float64
Y float64
K float64
R float64
G float64
B float64
A float64
}
(See the boxes and glue backend section on colors for details.)
If you need to transform a string to a *color.Color
value, use
where the string can be the name of a predefined color or an HTML / CSS value such as #FE1
or rgb(0.5.,0.5,0.5)
. These colors will be defined on the fly if they do not exist.
Predefined colors#
All CSS level 4 colors are predefined:
aliceblue
, antiquewhite
, aqua
, aquamarine
, azure
, beige
, bisque
, black
, blanchedalmond
, blue
, blueviolet
, brown
, burlywood
, cadetblue
, chartreuse
, chocolate
, coral
, cornflowerblue
, cornsilk
, crimson
, darkblue
, darkcyan
, darkgoldenrod
, darkgray
, darkgreen
, darkgrey
, darkkhaki
, darkmagenta
, darkolivegreen
, darkorange
, darkorchid
, darkred
, darksalmon
, darkseagreen
, darkslateblue
, darkslategray
, darkslategrey
, darkturquoise
, darkviolet
, deeppink
, deepskyblue
, dimgray
, dimgrey
, dodgerblue
, firebrick
, floralwhite
, forestgreen
, fuchsia
, gainsboro
, ghostwhite
, gold
, goldenrod
, gray
, green
, greenyellow
, grey
, honeydew
, hotpink
, indianred
, indigo
, ivory
, khaki
, lavender
, lavenderblush
, lawngreen
, lemonchiffon
, lightblue
, lightcoral
, lightcyan
, lightgoldenrodyellow
, lightgray
, lightgreen
, lightgrey
, lightpink
, lightsalmon
, lightseagreen
, lightskyblue
, lightslategray
, lightslategrey
, lightsteelblue
, lightyellow
, lime
, limegreen
, linen
, maroon
, mediumaquamarine
, mediumblue
, mediumorchid
, mediumpurple
, mediumseagreen
, mediumslateblue
, mediumspringgreen
, mediumturquoise
, mediumvioletred
, midnightblue
, mintcream
, mistyrose
, moccasin
, navajowhite
, navy
, oldlace
, olive
, olivedrab
, orange
, orangered
, orchid
, palegoldenrod
, palegreen
, paleturquoise
, palevioletred
, papayawhip
, peachpuff
, peru
, pink
, plum
, powderblue
, purple
, rebeccapurple
, red
, rosybrown
, royalblue
, saddlebrown
, salmon
, sandybrown
, seagreen
, seashell
, sienna
, silver
, skyblue
, slateblue
, slategray
, slategrey
, snow
, springgreen
, steelblue
, tan
, teal
, thistle
, tomato
, turquoise
, violet
, wheat
, white
, whitesmoke
, yellow
, and yellowgreen
.
Where black
and white
are defined in the gray color space and cyan
, magenta
, and yellow
are defined in the CMYK space. All other colors are defined in the RGB space. You can override the definitions if you need a different color space.
There are also HKS and Pantone colors predefined. See the source code for a complete list.