recpaint

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package recpaint implements a paint.Painter that records every operation into an in-memory log and can replay the log onto any other paint.Painter target. It fills the cairo_recording_surface gap left after the opengl branch dropped Cairo.

Use cases:

  • Scene cache: build a complex sub-scene once, replay cheaply on each frame instead of rebuilding it from scratch.
  • Multi-target export: render to screen + PDF + SVG from one traversal — record once, replay against three targets.
  • Debug / fixture capture: record a Painter session during a test, replay against an instrumented Painter to inspect every call ordering without modifying the producer.

Implementation: each Painter method captures its arguments in a closure and appends to ops. Replay iterates ops and calls each closure with the target. Closure-per-op trades a little allocation for code that's a 1:1 mirror of paint.Painter — easier to keep in sync when the interface gains a method.

Mirror state: CurrentPoint / CurrentState / GetMatrix return live answers based on the recorder's own CTM + state stack, so recording-time queries behave like a normal Painter rather than "undefined until replay".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RecordingPainter

type RecordingPainter struct {
	// contains filtered or unexported fields
}

RecordingPainter is the recorder. Construct with New(); drive it like any paint.Painter; call Replay to reproduce the operations on a real target.

Concurrency: not safe for concurrent use. One recorder per session.

func New

func New() *RecordingPainter

New constructs an empty RecordingPainter.

func (*RecordingPainter) Arc

func (r *RecordingPainter) Arc(xc, yc, radius, angle1, angle2 float64)

func (*RecordingPainter) ArcNegative

func (r *RecordingPainter) ArcNegative(xc, yc, radius, angle1, angle2 float64)

func (*RecordingPainter) Clip

func (r *RecordingPainter) Clip()

func (*RecordingPainter) ClipBounds

func (r *RecordingPainter) ClipBounds() (float64, float64, float64, float64)

func (*RecordingPainter) ClipBounds1

func (r *RecordingPainter) ClipBounds1() geom.Rect

func (*RecordingPainter) ClipPreserve

func (r *RecordingPainter) ClipPreserve()

func (*RecordingPainter) CurrentPoint

func (r *RecordingPainter) CurrentPoint() (float64, float64)

func (*RecordingPainter) CurrentState

func (r *RecordingPainter) CurrentState() int

func (*RecordingPainter) CurveTo

func (r *RecordingPainter) CurveTo(x1, y1, x2, y2, x3, y3 float64)

func (*RecordingPainter) DrawGlyph

func (r *RecordingPainter) DrawGlyph(glyph *paint.Glyph)

func (*RecordingPainter) DrawGlyphs

func (r *RecordingPainter) DrawGlyphs(glyphs []paint.Glyph)

func (*RecordingPainter) DrawIcon

func (r *RecordingPainter) DrawIcon(ico paint.Icon, fSize float64, grayed bool)

func (*RecordingPainter) DrawIcon1

func (r *RecordingPainter) DrawIcon1(ico paint.Icon, x, y, fSize float64, grayed bool)

func (*RecordingPainter) DrawPixmap

func (r *RecordingPainter) DrawPixmap(pixmap paint.Pixmap)

func (*RecordingPainter) DrawPixmap1

func (r *RecordingPainter) DrawPixmap1(x, y float64, pixmap paint.Pixmap)

func (*RecordingPainter) DrawPixmap2

func (r *RecordingPainter) DrawPixmap2(x, y float64, pixmap paint.Pixmap, x0, y0 float64)

func (*RecordingPainter) DrawPixmap5

func (r *RecordingPainter) DrawPixmap5(x, y, w, h float64, pixmap paint.Pixmap)

func (*RecordingPainter) DrawText

func (r *RecordingPainter) DrawText(text string)

func (*RecordingPainter) DrawText1

func (r *RecordingPainter) DrawText1(x, y float64, text string)

func (*RecordingPainter) Fill

func (r *RecordingPainter) Fill()

func (*RecordingPainter) FillPreserve

func (r *RecordingPainter) FillPreserve()

func (*RecordingPainter) Font

func (r *RecordingPainter) Font() paint.Font

func (*RecordingPainter) GetMatrix

func (r *RecordingPainter) GetMatrix(m *geom.Mat3x2)

func (*RecordingPainter) Line

func (r *RecordingPainter) Line(x1, y1, x2, y2 float64)

func (*RecordingPainter) LineTo

func (r *RecordingPainter) LineTo(x, y float64)

func (*RecordingPainter) MoveTo

func (r *RecordingPainter) MoveTo(x, y float64)

func (*RecordingPainter) OpCount

func (r *RecordingPainter) OpCount() int

OpCount reports how many ops have been recorded. Useful for tests and quick scene-complexity sniffing.

func (*RecordingPainter) Paint

func (r *RecordingPainter) Paint()

func (*RecordingPainter) PaintWithAlpha

func (r *RecordingPainter) PaintWithAlpha(alpha uint8)

func (*RecordingPainter) Rectangle

func (r *RecordingPainter) Rectangle(x, y, w, h float64)

func (*RecordingPainter) Rectangle1

func (r *RecordingPainter) Rectangle1(rect geom.Rect)

func (*RecordingPainter) Replay

func (r *RecordingPainter) Replay(target paint.Painter)

Replay iterates the recorded log and applies each op to target. The recorder is not consumed; multiple Replay calls fire identical op sequences. Order matters: a Save/Translate/Restore block on the recorder replays the same Save/Translate/Restore on target.

func (*RecordingPainter) Reset

func (r *RecordingPainter) Reset()

Reset clears the recorded log without touching mirror state. Use when reusing one recorder across frames where each frame's scene is independent — saves the New() allocation.

func (*RecordingPainter) ResetClip

func (r *RecordingPainter) ResetClip()

func (*RecordingPainter) ResetMatrix

func (r *RecordingPainter) ResetMatrix()

func (*RecordingPainter) Restore

func (r *RecordingPainter) Restore() int

func (*RecordingPainter) RestoreTo

func (r *RecordingPainter) RestoreTo(n int) bool

func (*RecordingPainter) Rotate

func (r *RecordingPainter) Rotate(radians float64)

func (*RecordingPainter) Save

func (r *RecordingPainter) Save() int

func (*RecordingPainter) Scale

func (r *RecordingPainter) Scale(sx, sy float64)

func (*RecordingPainter) ScaledFont

func (r *RecordingPainter) ScaledFont() paint.ScaledFont

func (*RecordingPainter) SetBrush

func (r *RecordingPainter) SetBrush(br paint.Brush)

func (*RecordingPainter) SetBrush1

func (r *RecordingPainter) SetBrush1(cr paint.Color)

func (*RecordingPainter) SetFont

func (r *RecordingPainter) SetFont(f paint.Font)

func (*RecordingPainter) SetMatrix

func (r *RecordingPainter) SetMatrix(m *geom.Mat3x2)

func (*RecordingPainter) SetOperator

func (r *RecordingPainter) SetOperator(op paint.Operator)

func (*RecordingPainter) SetPen

func (r *RecordingPainter) SetPen(pen paint.Pen)

func (*RecordingPainter) SetPen1

func (r *RecordingPainter) SetPen1(cr paint.Color, w float64)

func (*RecordingPainter) Stroke

func (r *RecordingPainter) Stroke()

func (*RecordingPainter) StrokePreserve

func (r *RecordingPainter) StrokePreserve()

func (*RecordingPainter) Target

func (r *RecordingPainter) Target() paint.Surface

func (*RecordingPainter) Transform

func (r *RecordingPainter) Transform(m *geom.Mat3x2)

func (*RecordingPainter) Translate

func (r *RecordingPainter) Translate(tx, ty float64)

Jump to

Keyboard shortcuts

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