avyos.dev/pkg/graphics/canvas

package canvas

Overview

No package-level documentation is provided.

Export GroupCount
Constants0
Variables0
Functions3
Types2

Functions

BufferFromImage

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

BufferFromImage copies any image.Image into a core buffer.

DecodeFile

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

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

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

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.

Functions

New

func New(width, height int) Canvas

New returns the default software canvas implementation.

DecodeOptions

type DecodeOptions struct {
	SVG gfxsvg.DecodeFileOptions
}

DecodeOptions controls image decode behavior.