painter

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BorderStyle

type BorderStyle struct {
	Color op.CallOp
}

type LineSplitter

type LineSplitter interface {
	// Split the line into runs and put the result in the runs array.
	Split(line lt.Line, runs *[]RenderRun)
}

LineSplitter defines the interface external styling source must implement to work with the painter. It used the Split api to split a line into a few RenderRuns.

type PolygonBuilder added in v0.5.0

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

PolygonBuilder detects how many polygons can be formed from a group of rectangles, then extarcts vertices for each of them. To draw the polygons in Gio, call Path or Paths to build the clip paths.

func NewPolygonBuilder added in v0.5.0

func NewPolygonBuilder(expandEmpty bool, minWidth int, radius float32) *PolygonBuilder

func (*PolygonBuilder) Group added in v0.5.0

func (pb *PolygonBuilder) Group(rects []image.Rectangle) [][]f32.Point

Group groups rectangles by horizontal overlap and generates polygon points for each group. Returns a slice of point slices, one per group.

func (*PolygonBuilder) Path added in v0.5.0

func (pb *PolygonBuilder) Path(gtx layout.Context, points []f32.Point) clip.PathSpec

Path creates a path with rounded corners from polygon points.

func (*PolygonBuilder) Paths added in v0.5.0

func (pb *PolygonBuilder) Paths(gtx layout.Context) []clip.PathSpec

type RenderRun

type RenderRun struct {
	Glyphs []text.Glyph
	// Offset is the pixel offset relative to the start of the line.
	Offset fixed.Int26_6

	// Fg is the text color encoded to Gio ops. This should be left empty
	// for runs originated from decorations.
	Fg op.CallOp
	// Bg is the background color encoded to Gio ops.
	Bg op.CallOp
	// Underline style for the run.
	Underline     *UnderlineStyle
	Squiggle      *SquiggleStyle
	Strikethrough *StrikethroughStyle
	Border        *BorderStyle
}

A RenderRun is a run of adjacent glyphs sharing the same style. This is used as the painting unit of the TextPainter.

func (*RenderRun) Advance

func (s *RenderRun) Advance() fixed.Int26_6

Advance returns the width of the run in pixels.

func (*RenderRun) Bounds

func (s *RenderRun) Bounds() image.Rectangle

Bounds returns the bounding box relative to the dot of the first glyph of the run.

func (*RenderRun) Size

func (s *RenderRun) Size() int

size returns the number of glyphs this run covers.

type SquiggleStyle

type SquiggleStyle struct {
	Color op.CallOp
}

type StrikethroughStyle

type StrikethroughStyle struct {
	Color op.CallOp
}

type TextPainter

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

TextPainter computes the bounding box of and paints text.

func (*TextPainter) Paint

func (tp *TextPainter) Paint(gtx layout.Context, shaper *text.Shaper, lines []lt.Line, defaultColor op.CallOp,
	syntaxTokens LineSplitter, decorations LineSplitter)

Paint paints text and various styles originated from syntax hignlighting or decorations.

func (*TextPainter) SetLineHeight added in v0.5.0

func (tp *TextPainter) SetLineHeight(lineHeight fixed.Int26_6)

func (*TextPainter) SetViewport

func (tp *TextPainter) SetViewport(viewport image.Rectangle, scrollOff image.Point)

type UnderlineStyle

type UnderlineStyle struct {
	Color op.CallOp
}

Jump to

Keyboard shortcuts

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