Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bounds ¶
type Bounds struct {
// Rect is a rectangular bounding box.
Rect math32.Box2
// Radius is the border radius for rounded rectangles, can be per corner
// or one value for all.
Radius sides.Floats
// Path is the computed clipping path for the Rect and Radius.
Path ppath.Path
}
Bounds represents an optimized rounded rectangle form of clipping, which is critical for GUI rendering.
type Context ¶
type Context struct {
// Style has the accumulated style values.
// Individual elements inherit from this style.
Style styles.Paint
// Transform is the transformation matrix for this stack level.
Transform math32.Matrix2
// Cumulative is the accumulated transformation matrix.
Cumulative math32.Matrix2
// Bounds is the rounded rectangle clip boundary.
// This is applied to the effective Path prior to adding to Render.
Bounds Bounds
// ClipPath is the current shape-based clipping path,
// in addition to the Bounds, which is applied to the effective Path
// prior to adding to Render.
ClipPath ppath.Path
// Mask is the current masking element, as rendered to a separate image.
// This is composited with the rendering output to produce the final result.
Mask image.Image
}
Context contains all of the rendering constraints / filters / masks that are applied to elements being rendered. For SVG compliant rendering, we need a stack of these Context elements that apply to all elements in the group. Each level always represents the compounded effects of any parent groups, with the compounding being performed when a new Context is pushed on the stack. https://www.w3.org/TR/SVG2/render.html#Grouping
func NewContext ¶
NewContext returns a new Context using given paint style, bounds, and parent Context. See Context.Init for details.
type ContextPop ¶
type ContextPop struct {
}
ContextPop is a Context pop render item, which can be used by renderers that track group structure (e.g., SVG).
func (*ContextPop) String ¶ added in v0.3.13
func (p *ContextPop) String() string
type ContextPush ¶
type ContextPush struct {
Context Context
}
ContextPush is a Context push render item, which can be used by renderers that track group structure (e.g., SVG).
func (*ContextPush) String ¶ added in v0.3.13
func (p *ContextPush) String() string
type Item ¶
Item is a union interface for render items: Path, Text, [Image], and ContextPush.
type Path ¶
type Path struct {
// Path specifies the shape(s) to be drawn, using commands:
// MoveTo, LineTo, QuadTo, CubeTo, ArcTo, and Close.
// Each command has the applicable coordinates appended after it,
// like the SVG path element. The coordinates are in the original
// units as specified in the Paint drawing commands, without any
// transforms applied. See [Path.Transform].
Path ppath.Path
// Context has the full accumulated style, transform, etc parameters
// for rendering the path, combining the current state context (e.g.,
// from any higher-level groups) with the current element's style parameters.
Context Context
}
Path is a path drawing render Item: responsible for all vector graphics drawing functionality.
type Render ¶
type Render []Item
Render is the sequence of painting [Item]s recorded from a [paint.Painter]
func (*Render) Clone ¶
Clone returns a copy of this Render, with shallow clones of the Items and Renderers lists.
type Renderer ¶
type Renderer interface {
// Render renders the given Render data.
Render(r Render) Renderer
// Size returns the size of the render target, in its preferred units.
// For [Image] types, it will be [units.UnitDot] to indicate the actual
// raw pixel size.
Size() (units.Units, math32.Vector2)
// SetSize sets the render size in given units. [units.UnitDot] is
// used for [Image] and [Draw] renderers. Direct configuration of
// other Renderer properties happens outside of this interface.
// This is used for resizing [Image] and [Draw] renderers when
// the relevant Scene size changes.
SetSize(un units.Units, size math32.Vector2)
// Image returns the rendered image after rendering.
// If nil, then images are not supported by this renderer.
Image() image.Image
// Source returns the document source code representation
// of the rendering output. This is supported by e.g., SVG
// and PDF renderers.
Source() []byte
}
Renderer is the interface for all backend rendering outputs.
type Text ¶
type Text struct {
// Text contains shaped Lines of text to be rendered, as produced by a
// [shaped.Shaper]. Typically this text is configured so that the
// Postion is at the upper left corner of the resulting text rendering.
Text *shaped.Lines
// Position to render, which typically specifies the upper left corner of
// the Text. This is added directly to the offsets and is transformed by the
// active transform matrix. See also PositionAbs
Position math32.Vector2
// Context has the full accumulated style, transform, etc parameters
// for rendering, combining the current state context (e.g.,
// from any higher-level groups) with the current element's style parameters.
Context Context
}
Text is a text rendering render item.