Documentation
¶
Overview ¶
Package gfx is the graphics model a document is drawn through: the Device interface, the devices behind it, color spaces, and the text, image and shading a device is handed.
It knows no file format. A PDF interpreter drives a Device and so does an HTML layout engine, and both reach the same renderer through it. What a device is given is already resolved: a path in user space, a run of glyphs with their transforms, an image that decodes on demand.
DrawDevice renders into a raster.Pixmap, TextDevice extracts, SVGDevice writes SVG, BBoxDevice measures, and ListDevice records what was drawn so that it can be drawn again. Embed BaseDevice to write another.
Index ¶
- Constants
- Variables
- func BandRows(w, h, rows, limit int) int
- func CropRect(box raster.Rect, dpi float64) image.Rectangle
- func CropTo(img *image.RGBA, box raster.Rect, dpi float64) *image.RGBA
- func DecodeRegistered(b []byte, limit int) (image.Image, bool, error)
- func HTMLDocument(title, body string) string
- func NamedColor(name string) (r, g, b uint8, ok bool)
- func NaturalDPI(st *TextPage, page raster.Rect, minArea float64, limit int) (dpi float64, box raster.Rect, crop bool)
- func RGBABands(origin image.Point, fn func(*image.RGBA) error) func(*raster.Pixmap) error
- func RegisterPictureDecoder(name, magic string, dec PictureDecoder)
- func ToRGBA(px *raster.Pixmap) *image.RGBA
- type BBoxDevice
- func (d *BBoxDevice) BeginMask(area raster.Rect, luminosity bool, cs *ColorSpace, backdrop []float32, ...)
- func (d *BBoxDevice) BeginTile(area, view raster.Rect, xstep, ystep float32, ctm raster.Matrix) int
- func (d *BBoxDevice) Bounds() raster.Rect
- func (d *BBoxDevice) ClipImageMask(img Image, ctm raster.Matrix, scissor raster.Rect)
- func (d *BBoxDevice) ClipPath(p *raster.Path, evenOdd bool, ctm raster.Matrix, scissor raster.Rect)
- func (d *BBoxDevice) ClipStrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
- func (d *BBoxDevice) ClipStrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
- func (d *BBoxDevice) ClipText(t *Text, ctm raster.Matrix, scissor raster.Rect)
- func (d *BBoxDevice) EndMask(*[256]uint8)
- func (d *BBoxDevice) EndTile()
- func (d *BBoxDevice) FillImage(img Image, ctm raster.Matrix, alpha float32, cp ColorParams)
- func (d *BBoxDevice) FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, c []float32, alpha float32, ...)
- func (d *BBoxDevice) FillPath(p *raster.Path, evenOdd bool, ctm raster.Matrix, cs *ColorSpace, c []float32, ...)
- func (d *BBoxDevice) FillShade(sh Shade, ctm raster.Matrix, alpha float32, cp ColorParams)
- func (d *BBoxDevice) FillText(t *Text, ctm raster.Matrix, cs *ColorSpace, c []float32, alpha float32, ...)
- func (d *BBoxDevice) PopClip()
- func (d *BBoxDevice) StrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, ...)
- func (d *BBoxDevice) StrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, c []float32, ...)
- type BaseDevice
- func (BaseDevice) BeginGroup(raster.Rect, *ColorSpace, bool, bool, BlendMode, float32)
- func (BaseDevice) BeginLayer(string)
- func (BaseDevice) BeginMask(raster.Rect, bool, *ColorSpace, []float32, ColorParams)
- func (BaseDevice) BeginTile(raster.Rect, raster.Rect, float32, float32, raster.Matrix) int
- func (BaseDevice) ClipImageMask(Image, raster.Matrix, raster.Rect)
- func (BaseDevice) ClipPath(*raster.Path, bool, raster.Matrix, raster.Rect)
- func (BaseDevice) ClipStrokePath(*raster.Path, *raster.Stroke, raster.Matrix, raster.Rect)
- func (BaseDevice) ClipStrokeText(*Text, *raster.Stroke, raster.Matrix, raster.Rect)
- func (BaseDevice) ClipText(*Text, raster.Matrix, raster.Rect)
- func (BaseDevice) Close() error
- func (BaseDevice) EndGroup()
- func (BaseDevice) EndLayer()
- func (BaseDevice) EndMask(*[256]uint8)
- func (BaseDevice) EndTile()
- func (b *BaseDevice) EnterGlyph(key any) bool
- func (BaseDevice) FillImage(Image, raster.Matrix, float32, ColorParams)
- func (BaseDevice) FillImageMask(Image, raster.Matrix, *ColorSpace, []float32, float32, ColorParams)
- func (BaseDevice) FillPath(*raster.Path, bool, raster.Matrix, *ColorSpace, []float32, float32, ...)
- func (BaseDevice) FillShade(Shade, raster.Matrix, float32, ColorParams)
- func (BaseDevice) FillText(*Text, raster.Matrix, *ColorSpace, []float32, float32, ColorParams)
- func (b *BaseDevice) GlyphOps() *int64
- func (BaseDevice) IgnoreText(*Text, raster.Matrix)
- func (b *BaseDevice) LeaveGlyph()
- func (BaseDevice) PopClip()
- func (BaseDevice) SetDefaultColorSpaces(*DefaultColorSpaces)
- func (BaseDevice) StrokePath(*raster.Path, *raster.Stroke, raster.Matrix, *ColorSpace, []float32, float32, ...)
- func (BaseDevice) StrokeText(*Text, *raster.Stroke, raster.Matrix, *ColorSpace, []float32, float32, ...)
- type BlendMode
- type ColorParams
- type ColorSpace
- func (cs *ColorSpace) CMYK(c []float32) (cyan, magenta, yellow, black float32)
- func (cs *ColorSpace) Clamp(c []float32)
- func (cs *ColorSpace) Convert(c []float32, out []uint8)
- func (cs *ColorSpace) Gray(c []float32) float32
- func (cs *ColorSpace) Initial() []float32
- func (cs *ColorSpace) IsPattern() bool
- func (cs *ColorSpace) LabRange() [4]float32
- func (cs *ColorSpace) Model() raster.Model
- func (cs *ColorSpace) RGB(c []float32) (r, g, b float32)
- type DefaultColorSpaces
- type Device
- type DrawDevice
- func (d *DrawDevice) BeginGroup(area raster.Rect, cs *ColorSpace, isolated, knockout bool, blend BlendMode, ...)
- func (d *DrawDevice) BeginMask(area raster.Rect, luminosity bool, cs *ColorSpace, backdrop []float32, ...)
- func (d *DrawDevice) BeginTile(area, view raster.Rect, xstep, ystep float32, ctm raster.Matrix) int
- func (d *DrawDevice) Clip() raster.Rect
- func (d *DrawDevice) ClipImageMask(img Image, ctm raster.Matrix, scissor raster.Rect)
- func (d *DrawDevice) ClipPath(p *raster.Path, evenOdd bool, ctm raster.Matrix, scissor raster.Rect)
- func (d *DrawDevice) ClipStrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
- func (d *DrawDevice) ClipStrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
- func (d *DrawDevice) ClipText(t *Text, ctm raster.Matrix, scissor raster.Rect)
- func (d *DrawDevice) EndGroup()
- func (d *DrawDevice) EndMask(transfer *[256]uint8)
- func (d *DrawDevice) EndTile()
- func (d *DrawDevice) FillImage(img Image, ctm raster.Matrix, alpha float32, cp ColorParams)
- func (d *DrawDevice) FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, col []float32, alpha float32, ...)
- func (d *DrawDevice) FillPath(p *raster.Path, evenOdd bool, ctm raster.Matrix, cs *ColorSpace, col []float32, ...)
- func (d *DrawDevice) FillShade(sh Shade, ctm raster.Matrix, alpha float32, cp ColorParams)
- func (d *DrawDevice) FillText(t *Text, ctm raster.Matrix, cs *ColorSpace, col []float32, alpha float32, ...)
- func (d *DrawDevice) Pixmap() *raster.Pixmap
- func (d *DrawDevice) PopClip()
- func (d *DrawDevice) SetErrorFunc(f func(error))
- func (d *DrawDevice) SetFlatness(tol float32)
- func (d *DrawDevice) SetGlyphCache(c *raster.GlyphCache)
- func (d *DrawDevice) StrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, ...)
- func (d *DrawDevice) StrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, col []float32, ...)
- type Font
- type GlyphRunner
- type ICC
- type Image
- type Kind
- type ListDevice
- func (d *ListDevice) BeginGroup(area raster.Rect, cs *ColorSpace, isolated, knockout bool, blend BlendMode, ...)
- func (d *ListDevice) BeginLayer(name string)
- func (d *ListDevice) BeginMask(area raster.Rect, luminosity bool, cs *ColorSpace, backdrop []float32, ...)
- func (d *ListDevice) BeginTile(area, view raster.Rect, xstep, ystep float32, ctm raster.Matrix) int
- func (d *ListDevice) Bounds() raster.Rect
- func (d *ListDevice) ClipImageMask(img Image, ctm raster.Matrix, scissor raster.Rect)
- func (d *ListDevice) ClipPath(path *raster.Path, evenOdd bool, ctm raster.Matrix, scissor raster.Rect)
- func (d *ListDevice) ClipStrokePath(path *raster.Path, stroke *raster.Stroke, ctm raster.Matrix, ...)
- func (d *ListDevice) ClipStrokeText(text *Text, stroke *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
- func (d *ListDevice) ClipText(text *Text, ctm raster.Matrix, scissor raster.Rect)
- func (d *ListDevice) Close() error
- func (d *ListDevice) DrawBands(r image.Rectangle, model raster.Model, alpha bool, rows, threads int, ...) error
- func (d *ListDevice) EndGroup()
- func (d *ListDevice) EndLayer()
- func (d *ListDevice) EndMask(transfer *[256]uint8)
- func (d *ListDevice) EndTile()
- func (d *ListDevice) FillImage(img Image, ctm raster.Matrix, alpha float32, cp ColorParams)
- func (d *ListDevice) FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, ...)
- func (d *ListDevice) FillPath(path *raster.Path, evenOdd bool, ctm raster.Matrix, cs *ColorSpace, ...)
- func (d *ListDevice) FillShade(shade Shade, ctm raster.Matrix, alpha float32, cp ColorParams)
- func (d *ListDevice) FillText(text *Text, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, ...)
- func (d *ListDevice) IgnoreText(text *Text, ctm raster.Matrix)
- func (d *ListDevice) Len() int
- func (d *ListDevice) PopClip()
- func (d *ListDevice) Replay(dev Device)
- func (d *ListDevice) ReplayClip(dev Device, clip raster.Rect)
- func (d *ListDevice) SetDefaultColorSpaces(defs *DefaultColorSpaces)
- func (d *ListDevice) StrokePath(path *raster.Path, stroke *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, ...)
- func (d *ListDevice) StrokeText(text *Text, stroke *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, ...)
- type Natural
- type Picture
- type PictureCache
- type PictureDecoder
- type PixelRows
- type Quad
- type RowImage
- type SVGDevice
- func (d *SVGDevice) BeginGroup(area raster.Rect, cs *ColorSpace, isolated, knockout bool, blend BlendMode, ...)
- func (d *SVGDevice) BeginLayer(name string)
- func (d *SVGDevice) BeginMask(area raster.Rect, luminosity bool, cs *ColorSpace, backdrop []float32, ...)
- func (d *SVGDevice) BeginTile(area, view raster.Rect, xstep, ystep float32, ctm raster.Matrix) int
- func (d *SVGDevice) ClipImageMask(img Image, ctm raster.Matrix, scissor raster.Rect)
- func (d *SVGDevice) ClipPath(p *raster.Path, evenOdd bool, ctm raster.Matrix, scissor raster.Rect)
- func (d *SVGDevice) ClipStrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
- func (d *SVGDevice) ClipStrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
- func (d *SVGDevice) ClipText(t *Text, ctm raster.Matrix, scissor raster.Rect)
- func (d *SVGDevice) Close() error
- func (d *SVGDevice) EndGroup()
- func (d *SVGDevice) EndLayer()
- func (d *SVGDevice) EndMask(transfer *[256]uint8)
- func (d *SVGDevice) EndTile()
- func (d *SVGDevice) FillImage(img Image, ctm raster.Matrix, alpha float32, cp ColorParams)
- func (d *SVGDevice) FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, ...)
- func (d *SVGDevice) FillPath(p *raster.Path, evenOdd bool, ctm raster.Matrix, cs *ColorSpace, ...)
- func (d *SVGDevice) FillShade(sh Shade, ctm raster.Matrix, alpha float32, cp ColorParams)
- func (d *SVGDevice) FillText(t *Text, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, ...)
- func (d *SVGDevice) PopClip()
- func (d *SVGDevice) StrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, ...)
- func (d *SVGDevice) StrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, color []float32, ...)
- type Shade
- type Text
- type TextBlock
- type TextChar
- type TextDevice
- func (d *TextDevice) ClipStrokeText(t *Text, stroke *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
- func (d *TextDevice) ClipText(t *Text, ctm raster.Matrix, scissor raster.Rect)
- func (d *TextDevice) Close() error
- func (d *TextDevice) FillImage(img Image, ctm raster.Matrix, alpha float32, cp ColorParams)
- func (d *TextDevice) FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, ...)
- func (d *TextDevice) FillText(t *Text, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, ...)
- func (d *TextDevice) IgnoreText(t *Text, ctm raster.Matrix)
- func (d *TextDevice) StrokeText(t *Text, stroke *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, ...)
- type TextItem
- type TextLine
- type TextOptions
- type TextPage
- type TextSpan
- type Tint
Constants ¶
const ( BlendNormal = raster.BlendNormal BlendMultiply = raster.BlendMultiply BlendScreen = raster.BlendScreen BlendOverlay = raster.BlendOverlay BlendDarken = raster.BlendDarken BlendLighten = raster.BlendLighten BlendColorDodge = raster.BlendColorDodge BlendColorBurn = raster.BlendColorBurn BlendHardLight = raster.BlendHardLight BlendSoftLight = raster.BlendSoftLight BlendDifference = raster.BlendDifference BlendExclusion = raster.BlendExclusion BlendHue = raster.BlendHue BlendSaturation = raster.BlendSaturation BlendColor = raster.BlendColor BlendLuminosity = raster.BlendLuminosity )
The separable blend modes, then the four non-separable ones.
const BookCropArea = 0.25
BookCropArea is CropArea for a page of a book.
const CropArea = 0.5
CropArea is the share of a page a picture covers before the page renders at its resolution, and before a page holding nothing else is taken to be that picture.
const DefaultDPI = 300
DefaultDPI is the resolution a page renders at when no image covers enough of it.
const DefaultPictureCacheBytes = 1 << 26
DefaultPictureCacheBytes is how many decoded samples a PictureCache keeps when its Bytes is zero.
const MinDPI = 72
MinDPI is the lowest resolution a page renders at for the image on it, one pixel a point.
const NaturalPixels = 1 << 26
NaturalPixels bounds the pixel area of a page rendered at its natural resolution.
Variables ¶
var ( DeviceGray = &ColorSpace{Name: "DeviceGray", Kind: KindGray, N: 1} DeviceRGB = &ColorSpace{Name: "DeviceRGB", Kind: KindRGB, N: 3} DeviceCMYK = &ColorSpace{Name: "DeviceCMYK", Kind: KindCMYK, N: 4} DevicePattern = &ColorSpace{Name: "Pattern", Kind: KindPattern, N: 1} )
The device spaces, which every content stream can use without declaring.
var DefaultColorParams = ColorParams{Intent: 1, BlackPoint: true}
DefaultColorParams is what a page starts with.
var ErrUnsupported = errors.New("gfx: unsupported")
ErrUnsupported is a picture in a form this cannot decode.
Functions ¶
func BandRows ¶ added in v0.3.0
BandRows returns the height of a band w pixels wide within limit pixels: rows, at most h, or as many as the limit allows when rows is zero or less, and zero when one row is over the limit.
func DecodeRegistered ¶ added in v0.2.4
DecodeRegistered decodes b with a registered decoder and reports whether one matched. A picture whose header gives more than limit pixels is refused.
func HTMLDocument ¶ added in v0.2.0
HTMLDocument wraps one page's division in the markup that makes it a page a browser will show on its own.
func NamedColor ¶
NamedColor is the color a keyword stands for, false for one that names none.
func NaturalDPI ¶ added in v0.2.3
func NaturalDPI(st *TextPage, page raster.Rect, minArea float64, limit int) (dpi float64, box raster.Rect, crop bool)
NaturalDPI is the resolution the largest image on the page is drawn at, and at least MinDPI, when it covers minArea of the page, DefaultDPI otherwise, lowered until the page fits in NaturalPixels and in limit pixels, and the box of that image, cropped to when no text is drawn. A negative limit is none.
func RGBABands ¶ added in v0.3.0
RGBABands adapts a callback taking RGBA bands to DrawBands, converting each band into one reused image whose Rect is the band's place in device space less origin.
func RegisterPictureDecoder ¶ added in v0.2.0
func RegisterPictureDecoder(name, magic string, dec PictureDecoder)
RegisterPictureDecoder installs a decoder for data beginning with magic, where "?" matches any byte.
gfx.RegisterPictureDecoder("jpeg", "\xff\xd8", func(b []byte) (image.Image, error) {
return jpegn.Decode(bytes.NewReader(b), &jpegn.Options{ToRGBA: true})
})
Types ¶
type BBoxDevice ¶
type BBoxDevice struct {
BaseDevice
// contains filtered or unexported fields
}
BBoxDevice accumulates the bounding box of everything drawn.
func NewBBoxDevice ¶
func NewBBoxDevice() *BBoxDevice
NewBBoxDevice returns a device that measures a page.
func (*BBoxDevice) BeginMask ¶
func (d *BBoxDevice) BeginMask(area raster.Rect, luminosity bool, cs *ColorSpace, backdrop []float32, cp ColorParams)
BeginMask implements Device.
func (*BBoxDevice) Bounds ¶
func (d *BBoxDevice) Bounds() raster.Rect
Bounds returns what has been drawn so far.
func (*BBoxDevice) ClipImageMask ¶
ClipImageMask implements Device.
func (*BBoxDevice) ClipStrokePath ¶
func (d *BBoxDevice) ClipStrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
ClipStrokePath implements Device.
func (*BBoxDevice) ClipStrokeText ¶
func (d *BBoxDevice) ClipStrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
ClipStrokeText implements Device.
func (*BBoxDevice) FillImage ¶
func (d *BBoxDevice) FillImage(img Image, ctm raster.Matrix, alpha float32, cp ColorParams)
FillImage implements Device.
func (*BBoxDevice) FillImageMask ¶
func (d *BBoxDevice) FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, c []float32, alpha float32, cp ColorParams)
FillImageMask implements Device.
func (*BBoxDevice) FillPath ¶
func (d *BBoxDevice) FillPath(p *raster.Path, evenOdd bool, ctm raster.Matrix, cs *ColorSpace, c []float32, alpha float32, cp ColorParams)
FillPath implements Device.
func (*BBoxDevice) FillShade ¶
func (d *BBoxDevice) FillShade(sh Shade, ctm raster.Matrix, alpha float32, cp ColorParams)
FillShade implements Device.
func (*BBoxDevice) FillText ¶
func (d *BBoxDevice) FillText(t *Text, ctm raster.Matrix, cs *ColorSpace, c []float32, alpha float32, cp ColorParams)
FillText implements Device.
func (*BBoxDevice) StrokePath ¶
func (d *BBoxDevice) StrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, c []float32, alpha float32, cp ColorParams)
StrokePath implements Device.
func (*BBoxDevice) StrokeText ¶
func (d *BBoxDevice) StrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, c []float32, alpha float32, cp ColorParams)
StrokeText implements Device.
type BaseDevice ¶
type BaseDevice struct {
// contains filtered or unexported fields
}
BaseDevice implements Device with no-ops.
func (BaseDevice) BeginGroup ¶
func (BaseDevice) BeginGroup(raster.Rect, *ColorSpace, bool, bool, BlendMode, float32)
func (BaseDevice) BeginLayer ¶
func (BaseDevice) BeginLayer(string)
func (BaseDevice) BeginMask ¶
func (BaseDevice) BeginMask(raster.Rect, bool, *ColorSpace, []float32, ColorParams)
func (BaseDevice) ClipImageMask ¶
func (BaseDevice) ClipStrokePath ¶
func (BaseDevice) ClipStrokeText ¶
func (BaseDevice) Close ¶
func (BaseDevice) Close() error
func (BaseDevice) EndGroup ¶
func (BaseDevice) EndGroup()
func (BaseDevice) EndLayer ¶
func (BaseDevice) EndLayer()
func (BaseDevice) EndMask ¶
func (BaseDevice) EndMask(*[256]uint8)
func (BaseDevice) EndTile ¶
func (BaseDevice) EndTile()
func (*BaseDevice) EnterGlyph ¶
func (b *BaseDevice) EnterGlyph(key any) bool
EnterGlyph reports whether a glyph procedure may run and pushes it; LeaveGlyph pops it.
func (BaseDevice) FillImage ¶
func (BaseDevice) FillImage(Image, raster.Matrix, float32, ColorParams)
func (BaseDevice) FillImageMask ¶
func (BaseDevice) FillImageMask(Image, raster.Matrix, *ColorSpace, []float32, float32, ColorParams)
func (BaseDevice) FillPath ¶
func (BaseDevice) FillPath(*raster.Path, bool, raster.Matrix, *ColorSpace, []float32, float32, ColorParams)
func (BaseDevice) FillShade ¶
func (BaseDevice) FillShade(Shade, raster.Matrix, float32, ColorParams)
func (BaseDevice) FillText ¶
func (BaseDevice) FillText(*Text, raster.Matrix, *ColorSpace, []float32, float32, ColorParams)
func (*BaseDevice) GlyphOps ¶ added in v0.2.8
func (b *BaseDevice) GlyphOps() *int64
GlyphOps is the count every glyph procedure run through the device adds to.
func (BaseDevice) IgnoreText ¶
func (BaseDevice) IgnoreText(*Text, raster.Matrix)
func (*BaseDevice) LeaveGlyph ¶
func (b *BaseDevice) LeaveGlyph()
func (BaseDevice) PopClip ¶
func (BaseDevice) PopClip()
func (BaseDevice) SetDefaultColorSpaces ¶
func (BaseDevice) SetDefaultColorSpaces(*DefaultColorSpaces)
func (BaseDevice) StrokePath ¶
func (BaseDevice) StrokePath(*raster.Path, *raster.Stroke, raster.Matrix, *ColorSpace, []float32, float32, ColorParams)
func (BaseDevice) StrokeText ¶
func (BaseDevice) StrokeText(*Text, *raster.Stroke, raster.Matrix, *ColorSpace, []float32, float32, ColorParams)
type ColorParams ¶
type ColorParams struct {
Intent int // 0 perceptual, 1 relative, 2 saturation, 3 absolute
BlackPoint bool // black point compensation
Overprint bool
OverprintMode int
OverprintStroke bool
}
ColorParams are the rendering intent and the flags of every painting operation.
type ColorSpace ¶
type ColorSpace struct {
Name string
Kind Kind
N int
// Base is the underlying space of an Indexed space and the underlying
// space of a Pattern space, when it has one.
Base *ColorSpace
// Alternate is the space a Separation or DeviceN falls back to.
Alternate *ColorSpace
// Lookup is the palette of an Indexed space: HiVal+1 entries of Base.N bytes.
Lookup []byte
// HiVal is the largest index of an Indexed space.
HiVal int
// Colorants names the inks of a Separation or DeviceN space.
Colorants []string
// Range bounds the a and b components of a Lab space.
Range []float64
// WhitePoint is the reference white of a CIE based space.
WhitePoint []float64
// Gamma and Matrix are the transfer values of a CalRGB or CalGray space.
Gamma []float64
Matrix []float64
// Tint maps colorant values to the alternate space.
Tint Tint
// ICC is the profile an ICCBased space embedded, when it is one this can
// read and one that says anything sRGB does not.
ICC *ICC
}
ColorSpace is a color space in the model of ISO 32000-1 8.6. What is here is what a device needs to know about one: how many components a color has, what it is called, and how to reach RGB.
func (*ColorSpace) CMYK ¶
func (cs *ColorSpace) CMYK(c []float32) (cyan, magenta, yellow, black float32)
CMYK converts a color in this space to CMYK.
func (*ColorSpace) Clamp ¶
func (cs *ColorSpace) Clamp(c []float32)
Clamp holds a color to the range its space allows.
func (*ColorSpace) Convert ¶
func (cs *ColorSpace) Convert(c []float32, out []uint8)
Convert writes a color of this space into out, in the space out's length implies: gray for one component, CMYK for four, RGB otherwise. A nil space converts black.
func (*ColorSpace) Gray ¶
func (cs *ColorSpace) Gray(c []float32) float32
Gray converts a color in this space to a single grey level.
func (*ColorSpace) Initial ¶
func (cs *ColorSpace) Initial() []float32
Initial returns the color a space starts at, ISO 32000-1 8.6.8.
func (*ColorSpace) IsPattern ¶
func (cs *ColorSpace) IsPattern() bool
IsPattern reports whether colors in this space name a pattern rather than carry component values.
func (*ColorSpace) LabRange ¶
func (cs *ColorSpace) LabRange() [4]float32
LabRange bounds the a and b components of a Lab space, from its /Range or from the default when it has none.
func (*ColorSpace) Model ¶
func (cs *ColorSpace) Model() raster.Model
Model returns the space as a raster.Model, which is all a pixmap needs to know about it: how many components it has, and how to reach RGB. The space has to be one a pixmap can hold, so one, three or four components whose values run from zero to one.
func (*ColorSpace) RGB ¶
func (cs *ColorSpace) RGB(c []float32) (r, g, b float32)
RGB converts a color in this space to RGB, each component in 0 to 1.
type DefaultColorSpaces ¶
type DefaultColorSpaces struct {
Gray, RGB, CMYK *ColorSpace
OutputIntent *ColorSpace
}
DefaultColorSpaces are the spaces the device spaces stand for and the output intent, ISO 32000-1 8.6.5.6.
func (*DefaultColorSpaces) Clone ¶
func (d *DefaultColorSpaces) Clone() *DefaultColorSpaces
Clone returns a copy, and an empty one for a nil receiver.
func (*DefaultColorSpaces) Default ¶
func (d *DefaultColorSpaces) Default(cs *ColorSpace) *ColorSpace
Default returns the space a device color space stands for.
type Device ¶
type Device interface {
FillPath(path *raster.Path, evenOdd bool, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
StrokePath(path *raster.Path, stroke *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
ClipPath(path *raster.Path, evenOdd bool, ctm raster.Matrix, scissor raster.Rect)
ClipStrokePath(path *raster.Path, stroke *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
FillText(text *Text, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
StrokeText(text *Text, stroke *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
ClipText(text *Text, ctm raster.Matrix, scissor raster.Rect)
ClipStrokeText(text *Text, stroke *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
IgnoreText(text *Text, ctm raster.Matrix)
FillShade(shade Shade, ctm raster.Matrix, alpha float32, cp ColorParams)
FillImage(img Image, ctm raster.Matrix, alpha float32, cp ColorParams)
FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
ClipImageMask(img Image, ctm raster.Matrix, scissor raster.Rect)
PopClip()
// SetDefaultColorSpaces reports the spaces device colors are interpreted in.
SetDefaultColorSpaces(d *DefaultColorSpaces)
// BeginMask opens a soft mask group that EndMask turns into a clip until popped.
BeginMask(area raster.Rect, luminosity bool, cs *ColorSpace, backdrop []float32, cp ColorParams)
EndMask(transfer *[256]uint8)
BeginGroup(area raster.Rect, cs *ColorSpace, isolated, knockout bool, blend BlendMode, alpha float32)
EndGroup()
BeginTile(area, view raster.Rect, xstep, ystep float32, ctm raster.Matrix) int
EndTile()
BeginLayer(name string)
EndLayer()
// Close is called when the page is finished.
Close() error
}
Device receives the drawing operations an interpreted document produces. Embed BaseDevice to pick up no-op implementations of everything.
type DrawDevice ¶
type DrawDevice struct {
BaseDevice
// contains filtered or unexported fields
}
DrawDevice renders into a raster.Pixmap, in the pixmap's own coordinates.
func NewDrawDevice ¶
func NewDrawDevice(dst *raster.Pixmap) *DrawDevice
NewDrawDevice returns a device that renders into dst.
func (*DrawDevice) BeginGroup ¶
func (d *DrawDevice) BeginGroup(area raster.Rect, cs *ColorSpace, isolated, knockout bool, blend BlendMode, alpha float32)
BeginGroup implements Device.
func (*DrawDevice) BeginMask ¶
func (d *DrawDevice) BeginMask(area raster.Rect, luminosity bool, cs *ColorSpace, backdrop []float32, cp ColorParams)
BeginMask implements Device.
func (*DrawDevice) BeginTile ¶
BeginTile implements Device. Returning zero asks the interpreter to run the pattern's content once for every repetition.
func (*DrawDevice) Clip ¶
func (d *DrawDevice) Clip() raster.Rect
Clip returns the rectangle drawing is confined to.
func (*DrawDevice) ClipImageMask ¶
ClipImageMask implements Device.
func (*DrawDevice) ClipStrokePath ¶
func (d *DrawDevice) ClipStrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
ClipStrokePath implements Device.
func (*DrawDevice) ClipStrokeText ¶
func (d *DrawDevice) ClipStrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
ClipStrokeText implements Device.
func (*DrawDevice) EndMask ¶
func (d *DrawDevice) EndMask(transfer *[256]uint8)
EndMask implements Device. The frame stays on the stack for PopClip.
func (*DrawDevice) FillImage ¶
func (d *DrawDevice) FillImage(img Image, ctm raster.Matrix, alpha float32, cp ColorParams)
FillImage implements Device.
func (*DrawDevice) FillImageMask ¶
func (d *DrawDevice) FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, col []float32, alpha float32, cp ColorParams)
FillImageMask implements Device.
func (*DrawDevice) FillPath ¶
func (d *DrawDevice) FillPath(p *raster.Path, evenOdd bool, ctm raster.Matrix, cs *ColorSpace, col []float32, alpha float32, cp ColorParams)
FillPath implements Device.
func (*DrawDevice) FillShade ¶
func (d *DrawDevice) FillShade(sh Shade, ctm raster.Matrix, alpha float32, cp ColorParams)
FillShade implements Device.
func (*DrawDevice) FillText ¶
func (d *DrawDevice) FillText(t *Text, ctm raster.Matrix, cs *ColorSpace, col []float32, alpha float32, cp ColorParams)
FillText implements Device.
func (*DrawDevice) Pixmap ¶
func (d *DrawDevice) Pixmap() *raster.Pixmap
Pixmap returns what has been drawn.
func (*DrawDevice) PopClip ¶
func (d *DrawDevice) PopClip()
PopClip implements Device. It also closes a group.
func (*DrawDevice) SetErrorFunc ¶
func (d *DrawDevice) SetErrorFunc(f func(error))
SetErrorFunc says where to report what went wrong on the way.
func (*DrawDevice) SetFlatness ¶
func (d *DrawDevice) SetFlatness(tol float32)
SetFlatness sets the distance a flattened curve may stray, in device pixels.
func (*DrawDevice) SetGlyphCache ¶
func (d *DrawDevice) SetGlyphCache(c *raster.GlyphCache)
SetGlyphCache gives the device somewhere to keep rendered glyph masks.
func (*DrawDevice) StrokePath ¶
func (d *DrawDevice) StrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, col []float32, alpha float32, cp ColorParams)
StrokePath implements Device.
func (*DrawDevice) StrokeText ¶
func (d *DrawDevice) StrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, col []float32, alpha float32, cp ColorParams)
StrokeText implements Device.
type Font ¶
type Font interface {
// FontName is the name the font goes by.
FontName() string
// Program is the font program the glyphs come from, and nil for a font
// that draws its glyphs by running procedures instead.
Program() *font.Font
// EmBox is how far the em box reaches above and below the baseline, in
// text space where one unit is the font size.
EmBox() (ascent, descent float32)
// RunGlyph draws one glyph into dev under ctm, which a font with no
// program has to do for itself. depth is how deep dev already is inside
// procedures that re-entered it.
RunGlyph(dev Device, gid int, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, depth int)
}
Font is the glyph source a text span names.
type GlyphRunner ¶
GlyphRunner is the part of a device a font uses to draw its own glyphs through it.
type ICC ¶
type ICC struct {
// contains filtered or unexported fields
}
ICC is what an embedded profile says about the numbers of a color space: the curve each channel is encoded with, and the matrix that takes the linear channels to the connection space. ISO 15076-1.
Only the matrix/TRC shape is read. A profile that maps through a table is left to the alternate space the file names.
func ParseICC ¶
ParseICC reads a profile, and returns nil for one this cannot use or one whose transform is the one sRGB already is.
func (*ICC) Components ¶
Components is how many channels the profile takes.
type Image ¶
type Image interface {
// Size is the image's own size in pixels.
Size() (w, h int)
// ColorSpace is the space the samples are in, and nil for a stencil.
ColorSpace() *ColorSpace
// Stencil reports a one bit mask, which paints the fill color through it.
Stencil() bool
// Smooth reports that the image asks to be interpolated.
Smooth() bool
// Pixels decodes the image into cs, halved shrink times. A nil cs asks
// for the coverage of a stencil, one byte a pixel.
Pixels(cs *ColorSpace, shrink int) (*raster.Pixmap, error)
}
Image is a picture a device draws, decoded only when it asks.
func DecodeImage ¶
DecodeImage decodes a raster picture into an Image.
type ListDevice ¶
type ListDevice struct {
// contains filtered or unexported fields
}
ListDevice records what a page draws so that it can be drawn again. One recording replays into as many destinations as a caller wants, which is what lets a page be rasterized in horizontal bands from several goroutines: every operation a raster renderer performs is local to the pixels it touches, so a band is the same page with a smaller destination.
func (*ListDevice) BeginGroup ¶
func (d *ListDevice) BeginGroup(area raster.Rect, cs *ColorSpace, isolated, knockout bool, blend BlendMode, alpha float32)
BeginGroup implements Device.
func (*ListDevice) BeginLayer ¶
func (d *ListDevice) BeginLayer(name string)
BeginLayer implements Device.
func (*ListDevice) BeginMask ¶
func (d *ListDevice) BeginMask(area raster.Rect, luminosity bool, cs *ColorSpace, backdrop []float32, cp ColorParams)
BeginMask implements Device.
func (*ListDevice) BeginTile ¶
BeginTile implements Device. A list records what the interpreter drew, and the interpreter only repeats a tile itself when the device says it will not, so the recording always holds every repetition.
func (*ListDevice) Bounds ¶
func (d *ListDevice) Bounds() raster.Rect
Bounds returns the union of what the list draws, in device space.
func (*ListDevice) ClipImageMask ¶
ClipImageMask implements Device.
func (*ListDevice) ClipPath ¶
func (d *ListDevice) ClipPath(path *raster.Path, evenOdd bool, ctm raster.Matrix, scissor raster.Rect)
ClipPath implements Device.
func (*ListDevice) ClipStrokePath ¶
func (d *ListDevice) ClipStrokePath(path *raster.Path, stroke *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
ClipStrokePath implements Device.
func (*ListDevice) ClipStrokeText ¶
func (d *ListDevice) ClipStrokeText(text *Text, stroke *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
ClipStrokeText implements Device.
func (*ListDevice) DrawBands ¶ added in v0.3.0
func (d *ListDevice) DrawBands(r image.Rectangle, model raster.Model, alpha bool, rows, threads int, newDevice func(*raster.Pixmap) Device, fn func(*raster.Pixmap) error) error
DrawBands draws the list into the area of device space r, rows at a time, and hands each band to fn in order from the top. A band is a pixmap of model whose X and Y are its place in device space, valid only until fn returns. newDevice makes the device a band is drawn through, threads bands are drawn at once, and an error from fn stops the drawing and is returned.
func (*ListDevice) EndMask ¶
func (d *ListDevice) EndMask(transfer *[256]uint8)
EndMask implements Device.
func (*ListDevice) FillImage ¶
func (d *ListDevice) FillImage(img Image, ctm raster.Matrix, alpha float32, cp ColorParams)
FillImage implements Device.
func (*ListDevice) FillImageMask ¶
func (d *ListDevice) FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
FillImageMask implements Device.
func (*ListDevice) FillPath ¶
func (d *ListDevice) FillPath(path *raster.Path, evenOdd bool, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
FillPath implements Device.
func (*ListDevice) FillShade ¶
func (d *ListDevice) FillShade(shade Shade, ctm raster.Matrix, alpha float32, cp ColorParams)
FillShade implements Device.
func (*ListDevice) FillText ¶
func (d *ListDevice) FillText(text *Text, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
FillText implements Device.
func (*ListDevice) IgnoreText ¶
func (d *ListDevice) IgnoreText(text *Text, ctm raster.Matrix)
IgnoreText implements Device.
func (*ListDevice) Len ¶
func (d *ListDevice) Len() int
Len returns how many device calls the list holds.
func (*ListDevice) Replay ¶
func (d *ListDevice) Replay(dev Device)
Replay draws the list into another device. It may be called any number of times, and from several goroutines at once as long as each is given a device of its own: a list is read-only once the page has been run into it.
func (*ListDevice) ReplayClip ¶
func (d *ListDevice) ReplayClip(dev Device, clip raster.Rect)
ReplayClip draws the list into another device, skipping what falls outside clip. What is skipped is only paint: a clip, a group or a layer runs wherever the list is replayed, because the calls after it depend on it.
func (*ListDevice) SetDefaultColorSpaces ¶
func (d *ListDevice) SetDefaultColorSpaces(defs *DefaultColorSpaces)
SetDefaultColorSpaces implements Device.
func (*ListDevice) StrokePath ¶
func (d *ListDevice) StrokePath(path *raster.Path, stroke *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
StrokePath implements Device.
func (*ListDevice) StrokeText ¶
func (d *ListDevice) StrokeText(text *Text, stroke *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
StrokeText implements Device.
type Natural ¶ added in v0.2.8
type Natural struct {
// contains filtered or unexported fields
}
Natural remembers what NaturalDPI gave one page; the zero value is ready to use.
type Picture ¶
type Picture struct {
// W and H are the picture's size in pixels.
W, H int
// contains filtered or unexported fields
}
Picture is a decoded raster image.
func DecodePicture ¶
DecodePicture decodes a raster picture with a registered or a standard decoder.
func NewPicture ¶
NewPicture wraps a premultiplied pixmap as a Picture without copying it.
func (*Picture) ColorSpace ¶
func (p *Picture) ColorSpace() *ColorSpace
ColorSpace implements gfx.Image.
type PictureCache ¶ added in v0.2.5
type PictureCache struct {
// Bytes bounds the decoded samples kept. Zero is DefaultPictureCacheBytes,
// negative is no cache at all.
Bytes int
// contains filtered or unexported fields
}
PictureCache holds the decoded pixels of the pictures opened through it, least recently drawn first to go. It is safe for concurrent use.
func (*PictureCache) Open ¶ added in v0.2.5
func (c *PictureCache) Open(b []byte) (*Picture, error)
Open reads how big a picture is and keeps b, which must not change afterwards, decoding the pixels only when a device draws the picture.
func (*PictureCache) Purge ¶ added in v0.2.5
func (c *PictureCache) Purge()
Purge drops every decoded picture the cache holds.
type PictureDecoder ¶ added in v0.2.0
PictureDecoder decodes one raster picture format.
type PixelRows ¶ added in v0.3.0
type PixelRows struct {
W, H int
Model raster.Model
Alpha bool
// Next returns the next row, valid until the next call, and false at the end.
Next func() ([]uint8, bool)
// Stop ends the decode.
Stop func()
}
PixelRows is an image's pixmap handed out a row at a time.
type RowImage ¶ added in v0.3.0
type RowImage interface {
Image
// PixelRows starts decoding the rows Pixels would build into cs, halved
// shrink times, top first; false when the image cannot be decoded so.
PixelRows(cs *ColorSpace, shrink int) (*PixelRows, bool)
}
RowImage is an Image that can also hand out its pixmap a row at a time.
type SVGDevice ¶
type SVGDevice struct {
BaseDevice
// contains filtered or unexported fields
}
SVGDevice writes what a page draws as SVG. Paths, text and images come out as themselves; a shading and a soft mask are rasterized.
func NewSVGDevice ¶
NewSVGDevice returns a device that writes the page bounded by box as SVG into w. Nothing reaches w until Close.
func (*SVGDevice) BeginGroup ¶
func (d *SVGDevice) BeginGroup(area raster.Rect, cs *ColorSpace, isolated, knockout bool, blend BlendMode, alpha float32)
BeginGroup implements Device.
func (*SVGDevice) BeginLayer ¶
BeginLayer implements Device.
func (*SVGDevice) BeginMask ¶
func (d *SVGDevice) BeginMask(area raster.Rect, luminosity bool, cs *ColorSpace, backdrop []float32, cp ColorParams)
BeginMask implements Device. The mask itself is not written; the group it opens is, so that the clip it becomes still pops.
func (*SVGDevice) BeginTile ¶
BeginTile implements Device. Returning zero asks for every repetition.
func (*SVGDevice) ClipImageMask ¶
ClipImageMask implements Device, clipping to what the stencil covers.
func (*SVGDevice) ClipStrokePath ¶
func (d *SVGDevice) ClipStrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
ClipStrokePath implements Device, clipping to what the stroke bounds.
func (*SVGDevice) ClipStrokeText ¶
func (d *SVGDevice) ClipStrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
ClipStrokeText implements Device.
func (*SVGDevice) FillImageMask ¶
func (d *SVGDevice) FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
FillImageMask implements Device, filling the stencil here: SVG has none.
func (*SVGDevice) FillPath ¶
func (d *SVGDevice) FillPath(p *raster.Path, evenOdd bool, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
FillPath implements Device.
func (*SVGDevice) FillText ¶
func (d *SVGDevice) FillText(t *Text, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
FillText implements Device.
func (*SVGDevice) StrokePath ¶
func (d *SVGDevice) StrokePath(p *raster.Path, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
StrokePath implements Device.
func (*SVGDevice) StrokeText ¶
func (d *SVGDevice) StrokeText(t *Text, s *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
StrokeText implements Device.
type Shade ¶
type Shade interface {
// Transform maps the shading's own space into the space ctm starts from.
Transform() raster.Matrix
// Bounds is the shading's bounding box in its own space, empty for none.
Bounds() raster.Rect
// ColorSpace is the space the shading's colors are in.
ColorSpace() *ColorSpace
// Shader returns what paints the shading into a destination of the given
// model, under ctm and over box, and nil when nothing is painted.
Shader(model raster.Model, ctm raster.Matrix, box raster.Rect) raster.Shader
}
Shade is a smooth gradation of color over an area, a shading or a gradient.
type Text ¶
type Text struct {
Spans []TextSpan
}
Text is what one text showing operator, or a run of them, hands to a device.
type TextBlock ¶
type TextBlock struct {
Bounds raster.Rect
// Lines are the block's lines, and nil for an image block.
Lines []TextLine
// Image is what an image block holds, and nil for a text block; Matrix
// maps the unit square onto the page.
Image Image
Matrix raster.Matrix
}
TextBlock is a paragraph of text, or one image.
type TextChar ¶
type TextChar struct {
Rune rune
// Origin is where the pen was, and Quad the em box over the advance.
Origin raster.Point
Quad Quad
Size float32
Font Font
Color [3]uint8
}
TextChar is one character where it was drawn.
type TextDevice ¶
type TextDevice struct {
BaseDevice
// contains filtered or unexported fields
}
TextDevice collects what a page draws into a TextPage.
func NewTextDevice ¶
func NewTextDevice(st *TextPage, opt *TextOptions) *TextDevice
NewTextDevice returns a device that collects the text of a page into st.
func (*TextDevice) ClipStrokeText ¶
func (d *TextDevice) ClipStrokeText(t *Text, stroke *raster.Stroke, ctm raster.Matrix, scissor raster.Rect)
ClipStrokeText implements Device.
func (*TextDevice) FillImage ¶
func (d *TextDevice) FillImage(img Image, ctm raster.Matrix, alpha float32, cp ColorParams)
FillImage implements Device.
func (*TextDevice) FillImageMask ¶
func (d *TextDevice) FillImageMask(img Image, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
FillImageMask implements Device.
func (*TextDevice) FillText ¶
func (d *TextDevice) FillText(t *Text, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
FillText implements Device.
func (*TextDevice) IgnoreText ¶
func (d *TextDevice) IgnoreText(t *Text, ctm raster.Matrix)
IgnoreText implements Device. Text that paints nothing is still text.
func (*TextDevice) StrokeText ¶
func (d *TextDevice) StrokeText(t *Text, stroke *raster.Stroke, ctm raster.Matrix, cs *ColorSpace, color []float32, alpha float32, cp ColorParams)
StrokeText implements Device.
type TextItem ¶
type TextItem struct {
X, Y float32
// GID is the glyph index in the font program, or -1 when the font engine
// has not resolved one.
GID int
// Rune is the Unicode value the character code maps to, or -1.
Rune rune
// Name is what the font program calls the glyph, when it names it.
Name string
// Code is the character code the string held, and CID what the font's
// encoding turned it into.
Code, CID uint32
// Adv is how far the pen moves, in text space units of the font size.
Adv float32
}
TextItem is one glyph placed by a text showing operator.
type TextLine ¶
type TextLine struct {
Bounds raster.Rect
// Dir is the unit vector the baseline runs along.
Dir raster.Point
WMode int
Chars []TextChar
}
TextLine is a run of characters along one baseline.
type TextOptions ¶
type TextOptions struct {
// Images records a block for every image drawn.
Images bool
// SkipHidden drops text drawn in a rendering mode that paints nothing.
SkipHidden bool
}
TextOptions configure a TextDevice.
type TextPage ¶
TextPage is a page's text: blocks of lines of characters, each with its box, in the order the page drew them.