recording/command.go

Functions Structs Interfaces

Functions

func Clone

Clone creates a deep copy of the Stroke.

func (s Stroke) Clone() Stroke {
	result := s
	if s.DashPattern != nil {
		result.DashPattern = make([]float64, len(s.DashPattern))
		copy(result.DashPattern, s.DashPattern)
	}
	return result
}

func DefaultImageOptions

DefaultImageOptions returns ImageOptions with default settings.

func DefaultImageOptions() ImageOptions {
	return ImageOptions{
		Interpolation:	InterpolationBilinear,
		Alpha:		1.0,
	}
}

func DefaultStroke

DefaultStroke returns a Stroke with default settings.

func DefaultStroke() Stroke {
	return Stroke{
		Width:		1.0,
		Cap:		LineCapButt,
		Join:		LineJoinMiter,
		MiterLimit:	4.0,
	}
}

func IsValid

IsValid returns true if the reference points to a valid path.

func (r PathRef) IsValid() bool {
	return uint32(r) != InvalidRef
}

func IsValid

IsValid returns true if the reference points to a valid brush.

func (r BrushRef) IsValid() bool {
	return uint32(r) != InvalidRef
}

func IsValid

IsValid returns true if the reference points to a valid image.

func (r ImageRef) IsValid() bool {
	return uint32(r) != InvalidRef
}

func String

String returns the string representation of a CommandType.

func (c CommandType) String() string {
	if int(c) < len(commandTypeNames) {
		return commandTypeNames[c]
	}
	return "Unknown"
}

func Type

Type implements Command.

func (DrawImageCommand) Type() CommandType	{ return CmdDrawImage }

func Type

Type implements Command.

func (SetStrokeStyleCommand) Type() CommandType	{ return CmdSetStrokeStyle }

func Type

Type implements Command.

func (ClipRoundRectCommand) Type() CommandType	{ return CmdClipRoundRect }

func Type

Type implements Command.

func (FillPathCommand) Type() CommandType	{ return CmdFillPath }

func Type

Type implements Command.

func (StrokePathCommand) Type() CommandType	{ return CmdStrokePath }

func Type

Type implements Command.

func (FillRectCommand) Type() CommandType	{ return CmdFillRect }

func Type

Type implements Command.

func (StrokeRectCommand) Type() CommandType	{ return CmdStrokeRect }

func Type

Type implements Command.

func (SetClipCommand) Type() CommandType	{ return CmdSetClip }

func Type

Type implements Command.

func (DrawTextCommand) Type() CommandType	{ return CmdDrawText }

func Type

Type implements Command.

func (StrokeTextCommand) Type() CommandType	{ return CmdStrokeText }

func Type

Type implements Command.

func (SetFillStyleCommand) Type() CommandType	{ return CmdSetFillStyle }

func Type

Type implements Command.

func (ClearClipCommand) Type() CommandType	{ return CmdClearClip }

func Type

Type implements Command.

func (SetLineWidthCommand) Type() CommandType	{ return CmdSetLineWidth }

func Type

Type implements Command.

func (SetLineCapCommand) Type() CommandType	{ return CmdSetLineCap }

func Type

Type implements Command.

func (SetLineJoinCommand) Type() CommandType	{ return CmdSetLineJoin }

func Type

Type implements Command.

func (SetMiterLimitCommand) Type() CommandType	{ return CmdSetMiterLimit }

func Type

Type implements Command.

func (SetDashCommand) Type() CommandType	{ return CmdSetDash }

func Type

Type implements Command.

func (SetFillRuleCommand) Type() CommandType	{ return CmdSetFillRule }

func Type

Type implements Command.

func (SetAntiAliasCommand) Type() CommandType	{ return CmdSetAntiAlias }

func Type

Type implements Command.

func (SetTransformCommand) Type() CommandType	{ return CmdSetTransform }

func Type

Type implements Command.

func (RestoreCommand) Type() CommandType	{ return CmdRestore }

func Type

Type implements Command.

func (SaveCommand) Type() CommandType	{ return CmdSave }

Structs

type SaveCommand struct

SaveCommand saves the current graphics state.

The state includes transform, clip, fill style, stroke style, and line properties.

type SaveCommand struct{}

type RestoreCommand struct

RestoreCommand restores the previously saved graphics state.

type RestoreCommand struct{}

type SetTransformCommand struct

SetTransformCommand sets the current transformation matrix.

type SetTransformCommand struct {
	// Matrix is the new transformation matrix.
	Matrix Matrix
}

type SetClipCommand struct

SetClipCommand sets the clipping region.

type SetClipCommand struct {
	// Path references the clip path in the resource pool.
	Path	PathRef
	// Rule specifies the fill rule for determining inside/outside.
	Rule	FillRule
}

type ClearClipCommand struct

ClearClipCommand clears the clipping region to the full canvas.

type ClearClipCommand struct{}

type ClipRoundRectCommand struct

ClipRoundRectCommand sets a rounded rectangle as the clipping region.

The rectangle is defined in user-space coordinates with a uniform corner radius.

type ClipRoundRectCommand struct {
	// X, Y is the top-left corner of the rectangle.
	X, Y	float64
	// W, H is the width and height of the rectangle.
	W, H	float64
	// Radius is the corner radius.
	Radius	float64
}

type FillPathCommand struct

FillPathCommand fills a path with a brush.

type FillPathCommand struct {
	// Path references the path to fill in the resource pool.
	Path	PathRef
	// Brush references the fill brush in the resource pool.
	Brush	BrushRef
	// Rule specifies the fill rule (non-zero or even-odd).
	Rule	FillRule
}

type StrokePathCommand struct

StrokePathCommand strokes a path with a brush.

type StrokePathCommand struct {
	// Path references the path to stroke in the resource pool.
	Path	PathRef
	// Brush references the stroke brush in the resource pool.
	Brush	BrushRef
	// Stroke contains the stroke style (width, cap, join, dash).
	Stroke	Stroke
}

type FillRectCommand struct

FillRectCommand fills a rectangle with a brush.

This is an optimization for the common case of axis-aligned rectangles.

type FillRectCommand struct {
	// Rect is the rectangle to fill.
	Rect	Rect
	// Brush references the fill brush in the resource pool.
	Brush	BrushRef
}

type StrokeRectCommand struct

StrokeRectCommand strokes a rectangle with a brush.

type StrokeRectCommand struct {
	// Rect is the rectangle to stroke.
	Rect	Rect
	// Brush references the stroke brush in the resource pool.
	Brush	BrushRef
	// Stroke contains the stroke style.
	Stroke	Stroke
}

type DrawImageCommand struct

DrawImageCommand draws an image.

type DrawImageCommand struct {
	// Image references the image in the resource pool.
	Image	ImageRef
	// SrcRect is the source rectangle in image coordinates.
	// If zero, uses the entire image.
	SrcRect	Rect
	// DstRect is the destination rectangle in canvas coordinates.
	DstRect	Rect
	// Options contains rendering options (interpolation, etc.).
	Options	ImageOptions
}

type DrawTextCommand struct

DrawTextCommand draws text at a specified position.

type DrawTextCommand struct {
	// Text is the string to render.
	Text	string
	// X is the horizontal position.
	X	float64
	// Y is the vertical position (baseline).
	Y	float64
	// FontSize is the size of the font in points.
	FontSize	float64
	// FontFamily is the name of the font family.
	FontFamily	string
	// Brush references the text color/brush in the resource pool.
	Brush	BrushRef
}

type StrokeTextCommand struct

StrokeTextCommand strokes text outlines at a specified position.

The stroke style (width, cap, join, dash) is captured at recording time.

type StrokeTextCommand struct {
	// Text is the string to render.
	Text	string
	// X is the horizontal position.
	X	float64
	// Y is the vertical position (baseline).
	Y	float64
	// FontSize is the size of the font in points.
	FontSize	float64
	// FontFamily is the name of the font family.
	FontFamily	string
	// Brush references the stroke color/brush in the resource pool.
	Brush	BrushRef
	// Stroke contains the stroke style (width, cap, join, dash).
	Stroke	Stroke
}

type SetFillStyleCommand struct

SetFillStyleCommand sets the fill brush.

type SetFillStyleCommand struct {
	// Brush references the fill brush in the resource pool.
	Brush BrushRef
}

type SetStrokeStyleCommand struct

SetStrokeStyleCommand sets the stroke brush.

type SetStrokeStyleCommand struct {
	// Brush references the stroke brush in the resource pool.
	Brush BrushRef
}

type SetLineWidthCommand struct

SetLineWidthCommand sets the stroke line width.

type SetLineWidthCommand struct {
	// Width is the line width in pixels.
	Width float64
}

type SetLineCapCommand struct

SetLineCapCommand sets the stroke line cap style.

type SetLineCapCommand struct {
	// Cap is the line cap style.
	Cap LineCap
}

type SetLineJoinCommand struct

SetLineJoinCommand sets the stroke line join style.

type SetLineJoinCommand struct {
	// Join is the line join style.
	Join LineJoin
}

type SetMiterLimitCommand struct

SetMiterLimitCommand sets the miter limit for line joins.

type SetMiterLimitCommand struct {
	// Limit is the miter limit value.
	Limit float64
}

type SetDashCommand struct

SetDashCommand sets the dash pattern for stroking.

type SetDashCommand struct {
	// Pattern is the dash pattern (alternating dash and gap lengths).
	// Nil or empty means solid line.
	Pattern	[]float64
	// Offset is the starting offset into the pattern.
	Offset	float64
}

type SetFillRuleCommand struct

SetFillRuleCommand sets the fill rule.

type SetFillRuleCommand struct {
	// Rule is the fill rule (non-zero or even-odd).
	Rule FillRule
}

type SetAntiAliasCommand struct

SetAntiAliasCommand enables or disables anti-aliasing for geometry rendering.

type SetAntiAliasCommand struct {
	// Enabled is true for anti-aliased rendering, false for aliased.
	Enabled bool
}

type Stroke struct

Stroke defines the style for stroking paths.

type Stroke struct {
	// Width is the line width in pixels.
	Width	float64
	// Cap is the shape of line endpoints.
	Cap	LineCap
	// Join is the shape of line joins.
	Join	LineJoin
	// MiterLimit is the limit for miter joins.
	MiterLimit	float64
	// DashPattern is the dash pattern (nil for solid line).
	DashPattern	[]float64
	// DashOffset is the starting offset into the dash pattern.
	DashOffset	float64
}

type ImageOptions struct

ImageOptions contains options for image rendering.

type ImageOptions struct {
	// Interpolation specifies the interpolation mode.
	Interpolation	InterpolationMode
	// Alpha is the opacity (0.0 to 1.0).
	Alpha	float64
}

Interfaces

type Command interface

Command is the interface implemented by all command types.

Commands represent individual drawing operations that can be

serialized and replayed to different backends.

type Command interface {
	// Type returns the CommandType for this command.
	Type() CommandType
}