painter

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 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) 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