canvas

package
v0.0.0-...-155abb7 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BufferFromImage

func BufferFromImage(img image.Image) *core.Buffer

BufferFromImage copies any image.Image into a core buffer.

func DecodeFile

func DecodeFile(path string) (image.Image, error)

DecodeFile decodes a raster image file into an image.Image.

func DecodeImageToBuffer

func DecodeImageToBuffer(path string, reqSize int, opts ...DecodeOptions) (*core.Buffer, error)

DecodeImageToBuffer decodes raster formats and delegates SVG decoding to pkg/graphics/svg.

Types

type Canvas

type Canvas interface {
	Buffer() *core.Buffer
	Image() draw.Image
	Size() (width, height int)

	SetClip(r image.Rectangle)
	ClearClip()
	Clip() (image.Rectangle, bool)

	Clear(fill color.Color)
	SetPixel(x, y int, c color.Color)
	GetPixel(x, y int) color.NRGBA

	FillRect(r image.Rectangle, fill color.Color)
	DrawRect(r image.Rectangle, stroke color.Color)
	FillRoundedRect(r image.Rectangle, radius int, fill color.Color)
	DrawRoundedRect(r image.Rectangle, radius int, stroke color.Color)
	DrawLine(x0, y0, x1, y1 int, stroke color.Color)

	DrawImage(src image.Image, dst image.Rectangle)
	DrawBuffer(src *core.Buffer, dst image.Rectangle)
}

Canvas defines the drawing surface API used by renderers.

func New

func New(width, height int) Canvas

New returns the default software canvas implementation.

type DecodeOptions

type DecodeOptions struct {
	SVG gfxsvg.DecodeFileOptions
}

DecodeOptions controls image decode behavior.

Jump to

Keyboard shortcuts

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