export

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package export holds what the writers of PDF and PostScript files share: the pen that writes the segments of Canvas paths as the operators of both, and the readings of a document's paints and instructions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClampShadow

func ClampShadow(v float64) float64

ClampShadow bounds a number of a shadow (its blur, its offsets).

func F64

func F64(in bdf.Instr, i int) float64

F64 is a number argument of an instruction, 0 when it is not finite.

func Fine

func Fine(v float64) string

Fine writes a number that is multiplied by a size (a scale of a matrix, a width of a glyph, a component of a color), with more decimals than Num (six).

func IsSVG

func IsSVG(b []byte) bool

IsSVG tells an SVG document from the other images a document holds.

func Mat

func Mat(m affine.Matrix) string

Mat writes a matrix as the operands of a cm, a text, font, pattern or image matrix: its scales finely, its offsets as places.

func Num

func Num(v float64) string

Num writes a number of a content stream, a dictionary or a procedure: without an exponent, with as many decimals as a place on a page or a color needs (four), within what single precision holds (the numbers of PDF and the reals of PostScript are single precision).

func Nums

func Nums(vs ...float64) string

Nums writes numbers with spaces between them.

func U64

func U64(in bdf.Instr, i int) uint64

U64 is an index argument of an instruction.

Types

type Pen

type Pen struct {
	B *bytes.Buffer
	M affine.Matrix

	// Drawn says the path has segments; Box is the box of their points,
	// when Boxed.
	Drawn bool
	Box   [4]float64
	Boxed bool
	// contains filtered or unexported fields
}

Pen writes the segments of a path as the operators m, l, c and h (of a PDF content stream, or of the procedures of psbdf's prolog), with the rules of Canvas paths: a segment without a subpath starts one, and a closed subpath is followed by one that starts where it started. It keeps the box of the points it writes; with no buffer it only keeps the box. It is an sfnt.Pen, for the outlines of glyphs in font units under its transform.

func NewPen

func NewPen(b *bytes.Buffer, m affine.Matrix) *Pen

NewPen makes a pen that writes to b (nil: keeps the box only) through the transform m.

func (*Pen) ArcTo

func (p *Pen) ArcTo(x1, y1, x2, y2, r float64)

ArcTo adds a line and an arc of radius r tangent to the lines from the current point to (x1, y1) and from there to (x2, y2).

func (*Pen) Close

func (p *Pen) Close()

func (*Pen) CubeTo

func (p *Pen) CubeTo(c1x, c1y, c2x, c2y, x, y float64)

func (*Pen) Ellipse

func (p *Pen) Ellipse(cx, cy, rx, ry, rot, a0, a1 float64, ccw bool)

Ellipse adds an elliptical arc with Canvas semantics: a line from the current point to the start of the arc, angles measured clockwise from the x axis (y down) and rotated by rot.

func (*Pen) LineTo

func (p *Pen) LineTo(x, y float64)

func (*Pen) MoveTo

func (p *Pen) MoveTo(x, y float64)

func (*Pen) Path

func (p *Pen) Path(bp *bdf.Path)

Path writes a path of a document, moved by the transform.

func (*Pen) QuadTo

func (p *Pen) QuadTo(cx, cy, x, y float64)

func (*Pen) Rect

func (p *Pen) Rect(x, y, w, h float64)

func (*Pen) RoundRect

func (p *Pen) RoundRect(x, y, w, h, r float64)

RoundRect adds a rectangle with corners rounded by r (Canvas roundRect with one radius).

type Source

type Source struct {
	Doc *bdf.Document
	// SkipRoles are the roles of the layers that are not written.
	SkipRoles []string
	// Warnings are the warnings of the writing, each once.
	Warnings []string
	// Seen holds the objects written before (see Enter).
	Seen map[bdf.Hash]struct{}
	// contains filtered or unexported fields
}

Source is the document a writer writes, with what it has decoded of it and the warnings of the writing. A writer embeds it.

func (*Source) Enter

func (s *Source) Enter(h bdf.Hash) bool

Enter notes an object as written and reports whether it was before.

func (*Source) Object

func (s *Source) Object(h bdf.Hash) *bdf.ObjectPart

Object is an object of the document, decoded once; nil (with a warning) for one that is missing or cannot be read.

func (*Source) Path

func (s *Source) Path(obj *bdf.ObjectPart, i int) *bdf.Path

Path is a path of an object: inline, or of a path collection of the document, decoded once; nil (with a warning) for one there is not.

func (*Source) Skip

func (s *Source) Skip(role string) bool

Skip reports whether the layers of a role are not written.

func (*Source) Warnf

func (s *Source) Warnf(format string, args ...any)

Warnf adds a warning, once.

type Stop

type Stop struct {
	Off     float64
	R, G, B float64
	A       float64
}

Stop is a stop of a gradient: its offset and its color, as fractions.

func StopsOf

func StopsOf(p *bdf.Paint) []Stop

StopsOf reads the stops of a gradient in their order: a stop before the one before it is at its place, and one past 1 at 1.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL