canvas2d

package
v0.1.0 Latest Latest
Warning

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

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

Rendered for js/wasm

Overview

Package canvas2d plays NSGo's drawings into a canvas's 2D context over syscall/js: a browser's <canvas> on the web, and a WeChat mini program's offscreen canvas, which has the same context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Player

type Player struct {
	Ctx js.Value
	// Ratio is the canvas's pixels per point, and Size its diagonal in
	// points, which repeating gradients cover.
	Ratio, Size float64
	// Font is the context's font shorthand of a font.
	Font func(driver.Font) string
	// Image returns the loaded image an op draws and its pixels per
	// point; false while it loads, when the op draws nothing.
	Image func(driver.ImageSource) (img js.Value, density float64, ok bool)
	// contains filtered or unexported fields
}

Player plays a drawing into a 2D context, which draws as NSGo's: the context already does what the ops say, so most map one to one.

func NewPlayer

func NewPlayer(ctx js.Value, ratio, size float64) *Player

NewPlayer returns a player into ctx, whose canvas has ratio pixels per point and a diagonal of size points.

func (*Player) Play

func (p *Player) Play(op *driver.DrawOp)

Play plays op.

Jump to

Keyboard shortcuts

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