canvasmesh

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 8 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

Overview

Package canvasmesh plays triangle meshes for canvas contexts without textured vertices. The native player composites the result as one image.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Draw

func Draw(dst Target, op *driver.DrawOp, texture Texture)

Draw draws op's triangles into dst, which spans op's bounds, as Raster does.

func Raster

func Raster(op *driver.DrawOp, texture Texture, scale float64) *image.RGBA

Raster draws op's triangles in its bounds at scale pixels per point. Shared edges pass the same half-open coverage rule as GPU triangles, so no pixel along the join is drawn twice or left empty.

Types

type Target

type Target struct {
	Pix                   []byte
	Width, Height, Stride int
	X, Y, ScaleX, ScaleY  float64
	BGRA                  bool
}

Target is the zeroed premultiplied pixels Draw draws into, with four bytes per pixel in BGRA order when BGRA is set and RGBA order otherwise. Its top left corner is canvas point X, Y, and it has ScaleX and ScaleY pixels per point.

func Bounds

func Bounds(op *driver.DrawOp, texture Texture, scale float64) Target

Bounds returns a Target without pixels that spans op's bounds at scale pixels per point, at most 4096 pixels a side and 4M in all. Its Width is zero when op draws nothing.

func Device

func Device(op *driver.DrawOp, texture Texture, sx, sy, tx, ty float64) (Target, bool)

Device returns a Target without pixels whose pixels are the device's, for a context that maps canvas point x, y to device pixel x*sx+tx, y*sy+ty, so compositing it copies pixels rather than resampling them. When that takes more pixels than Bounds allows, it returns Bounds at the larger scale and false.

type Texture

type Texture struct {
	Pix                   []byte
	Width, Height, Stride int
	Points                driver.Size
	BGRA                  bool
}

Texture is a read-only premultiplied image, with four bytes per pixel.

func RGBA

func RGBA(img *image.RGBA, size driver.Size) Texture

RGBA uses the pixels of img without copying them.

Jump to

Keyboard shortcuts

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