Documentation ¶
Overview ¶
Package color implements the PDF color spaces and colors.
Index ¶
- Variables
- func CheckCurrent(cur, new Color) (needsColorSpace bool, needsColor bool)
- func CheckVersion(cs Space, v pdf.Version) error
- func IsIndexed(s Space) bool
- func IsPattern(s Space) bool
- func NumValues(s Space) int
- func Operator(c Color) ([]float64, pdf.Resource, string)
- type Color
- type PatternColored
- type Space
- type SpaceCalGray
- type SpaceCalRGB
- type SpaceDeviceCMYK
- type SpaceDeviceGray
- type SpaceDeviceRGB
- type SpaceIndexed
- type SpaceLab
- type TilingPatternUncolored
Constants ¶
This section is empty.
Variables ¶
var ( // WhitePointD65 represents the D65 whitepoint. // The given values are CIE 1931 XYZ coordinates. // // https://en.wikipedia.org/wiki/Illuminant_D65 WhitePointD65 = []float64{0.95047, 1.0, 1.08883} // WhitePointD50 represents the D50 whitepoint. // The given values are CIE 1931 XYZ coordinates. // // https://en.wikipedia.org/wiki/Standard_illuminant#Illuminant_series_D WhitePointD50 = []float64{0.964212, 1.0, 0.8251883} )
var ( // DeviceGray is the DeviceGray color space. DeviceGray = SpaceDeviceGray{} // DeviceRGB is the DeviceRGB color space. DeviceRGB = SpaceDeviceRGB{} // DeviceCMYK is the DeviceCMYK color space. DeviceCMYK = SpaceDeviceCMYK{} )
Functions ¶
func CheckCurrent ¶
CheckCurrent checks whether the changing from the current color to the new color requires a color space change and/or a color change.
func CheckVersion ¶
CheckVersion checks whether the given color space can be used in the given PDF version.
func IsIndexed ¶ added in v0.4.2
IsIndexed returns whether the given color space is an indexed color space.
func IsPattern ¶ added in v0.4.2
IsPattern returns whether the given color space is a pattern color space.
func NumValues ¶ added in v0.4.2
NumValues returns the number of color values for the given color space.
Types ¶
type Color ¶
type Color interface { ColorSpace() Space // contains filtered or unexported methods }
Color represents a PDF color.
type PatternColored ¶ added in v0.4.2
PatternColored represents a colored tiling pattern or a shading pattern.
In case of a colored tiling pattern, `Res.Data“ must be a PDF stream defining a pattern with PatternType 1 and PaintType 1. In case of a shading pattern, `Res.Data“ must be a PDF pattern dictionary with PatternType 2.
func (PatternColored) ColorSpace ¶ added in v0.4.2
func (c PatternColored) ColorSpace() Space
ColorSpace implements the Color interface.
type Space ¶
type Space interface { pdf.Resource ColorSpaceFamily() string // contains filtered or unexported methods }
Space represents a PDF color space.
type SpaceCalGray ¶
SpaceCalGray represents a CalGray color space.
func CalGray ¶
func CalGray(whitePoint, blackPoint []float64, gamma float64, defName pdf.Name) (*SpaceCalGray, error)
CalGray returns a new CalGray color space.
WhitePoint is the diffuse white point in CIE 1931 XYZ coordinates. This must be a slice of length 3, with positive entries, and Y=1.
BlackPoint (optional) is the diffuse black point in the CIE 1931 XYZ coordinates. If non-nil, this must be a slice of three non-negative numbers. The default is [0 0 0].
The gamma parameter is a positive number (usually greater than or equal to 1).
DefName is the default resource name to use within content streams. This can be left empty to allocate names automatically.
func (*SpaceCalGray) ColorSpaceFamily ¶
func (s *SpaceCalGray) ColorSpaceFamily() string
ColorSpaceFamily implements the [ColorSpace] interface.
func (*SpaceCalGray) Embed ¶
func (s *SpaceCalGray) Embed(out *pdf.Writer) (*SpaceCalGray, error)
Embed embeds the color space in the PDF file. This saves space in case the color space is used in multiple content streams.
func (*SpaceCalGray) New ¶
func (s *SpaceCalGray) New(gray float64) Color
New returns a new CalGray color.
type SpaceCalRGB ¶
SpaceCalRGB represents a CalRGB color space.
func CalRGB ¶
func CalRGB(whitePoint, blackPoint, gamma, matrix []float64, defName pdf.Name) (*SpaceCalRGB, error)
CalRGB returns a new CalRGB color space.
WhitePoint is the diffuse white point in CIE 1931 XYZ coordinates. This must be a slice of length 3, with positive entries, and Y=1.
BlackPoint (optional) is the diffuse black point in the CIE 1931 XYZ coordinates. If non-nil, this must be a slice of three non-negative numbers. The default is [0 0 0].
Gamma (optional) gives the gamma values for the red, green and blue components. If non-nil, this must be a slice of three numbers. The default is [1 1 1].
Matrix (optional) is a 3x3 matrix. The default is [1 0 0 0 1 0 0 0 1].
DefName is the default resource name to use within content streams. This can be left empty to allocate names automatically.
func (*SpaceCalRGB) ColorSpaceFamily ¶
func (s *SpaceCalRGB) ColorSpaceFamily() string
ColorSpaceFamily implements the [ColorSpace] interface.
func (*SpaceCalRGB) Embed ¶
func (s *SpaceCalRGB) Embed(out *pdf.Writer) (*SpaceCalRGB, error)
Embed embeds the color space in the PDF file. This saves space in case the color space is used in multiple content streams.
func (*SpaceCalRGB) New ¶
func (s *SpaceCalRGB) New(r, g, b float64) Color
New returns a new CalRGB color.
type SpaceDeviceCMYK ¶
type SpaceDeviceCMYK struct{}
SpaceDeviceCMYK represents the DeviceCMYK color space. Use DeviceCMYK to access this color space.
func (SpaceDeviceCMYK) ColorSpaceFamily ¶
func (s SpaceDeviceCMYK) ColorSpaceFamily() string
ColorSpaceFamily implements the [ColorSpace] interface.
func (SpaceDeviceCMYK) DefaultName ¶
func (s SpaceDeviceCMYK) DefaultName() pdf.Name
DefaultName implements the [ColorSpace] interface.
func (SpaceDeviceCMYK) New ¶
func (s SpaceDeviceCMYK) New(c, m, y, k float64) Color
New returns a color in the DeviceCMYK color space.
func (SpaceDeviceCMYK) PDFObject ¶
func (s SpaceDeviceCMYK) PDFObject() pdf.Object
PDFObject implements the [ColorSpace] interface.
type SpaceDeviceGray ¶
type SpaceDeviceGray struct{}
SpaceDeviceGray represents the DeviceGray color space. Use DeviceGray to access this color space.
func (SpaceDeviceGray) ColorSpaceFamily ¶
func (s SpaceDeviceGray) ColorSpaceFamily() string
ColorSpaceFamily implements the [ColorSpace] interface.
func (SpaceDeviceGray) DefaultName ¶
func (s SpaceDeviceGray) DefaultName() pdf.Name
DefaultName implements the [ColorSpace] interface.
func (SpaceDeviceGray) New ¶
func (s SpaceDeviceGray) New(gray float64) Color
New returns a color in the DeviceGray color space.
func (SpaceDeviceGray) PDFObject ¶
func (s SpaceDeviceGray) PDFObject() pdf.Object
PDFObject implements the [ColorSpace] interface.
type SpaceDeviceRGB ¶
type SpaceDeviceRGB struct{}
SpaceDeviceRGB represents the DeviceRGB color space. Use DeviceRGB to access this color space.
func (SpaceDeviceRGB) ColorSpaceFamily ¶
func (s SpaceDeviceRGB) ColorSpaceFamily() string
ColorSpaceFamily implements the [ColorSpace] interface.
func (SpaceDeviceRGB) DefaultName ¶
func (s SpaceDeviceRGB) DefaultName() pdf.Name
DefaultName implements the [ColorSpace] interface.
func (SpaceDeviceRGB) New ¶
func (s SpaceDeviceRGB) New(r, g, b float64) Color
New returns a color in the DeviceRGB color space.
func (SpaceDeviceRGB) PDFObject ¶
func (s SpaceDeviceRGB) PDFObject() pdf.Object
PDFObject implements the [ColorSpace] interface.
type SpaceIndexed ¶
SpaceIndexed represents an indexed color space.
func Indexed ¶
func Indexed(colors []Color, defName pdf.Name) (*SpaceIndexed, error)
Indexed returns a new indexed color space.
The colors must all have the same color space, and the number of colors must be between 1 and 256.
func (*SpaceIndexed) ColorSpaceFamily ¶
func (s *SpaceIndexed) ColorSpaceFamily() string
ColorSpaceFamily implements the [ColorSpace] interface.
func (*SpaceIndexed) Embed ¶
func (s *SpaceIndexed) Embed(out *pdf.Writer) (*SpaceIndexed, error)
Embed embeds the color space in the PDF file. This saves space in case the color space is used in multiple content streams.
func (*SpaceIndexed) New ¶
func (s *SpaceIndexed) New(idx int) Color
New returns a new indexed color.
type SpaceLab ¶
SpaceLab represents a CIE 1976 L*a*b* color space.
func Lab ¶
Lab returns a new CIE 1976 L*a*b* color space.
WhitePoint is the diffuse white point in CIE 1931 XYZ coordinates. This must be a slice of length 3, with positive entries, and Y=1.
BlackPoint (optional) is the diffuse black point in the CIE 1931 XYZ coordinates. If non-nil, this must be a slice of three non-negative numbers. The default is [0 0 0].
Ranges (optional) is a slice of four numbers, [aMin, aMax, bMin, bMax], which define the valid range of the a* and b* components. The default is [-100 100 -100 100].
DefName is the default resource name to use within content streams. This can be left empty to allocate names automatically.
func (*SpaceLab) ColorSpaceFamily ¶
ColorSpaceFamily implements the [ColorSpace] interface.
type TilingPatternUncolored ¶ added in v0.4.2
TilingPatternUncolored represents an uncolored PDF tiling pattern.
Res.Data must be a PDF stream defining a pattern with PatternType 1 and PaintType 2.
func (*TilingPatternUncolored) New ¶ added in v0.4.2
func (p *TilingPatternUncolored) New(col Color) Color
New returns a Color which paints the given tiling pattern in the given color.