Documentation
¶
Index ¶
- Constants
- type CanvasElement
- func (c *CanvasElement) AddEventListener(eventType EventType, handler EventHandler) (handle *EventHandlerHandle)
- func (c *CanvasElement) ElementSize() (width, height float64)
- func (c *CanvasElement) GetContext(contextId string, opts js.Value) (context js.Value)
- func (c *CanvasElement) RemoveEventListener(handle *EventHandlerHandle)
- func (c *CanvasElement) Revision() (revision uint64)
- func (c *CanvasElement) Size() (width, height float64)
- func (c *CanvasElement) WasmDrawSource() (src Source)
- type CanvasImageSource
- type EventHandler
- type EventHandlerHandle
- type EventType
- type FrameCallback
- type FrameLoop
- type FrameSurface
- type Image
- type ImageBitmap
- type OffscreenCanvas
- func (c *OffscreenCanvas) GetContext(contextID string, opts js.Value) (ctx js.Value)
- func (c *OffscreenCanvas) Revision() (revision uint64)
- func (c *OffscreenCanvas) SetSize(width, height float64)
- func (c *OffscreenCanvas) SetSourcePreparation(prepare func())
- func (c *OffscreenCanvas) Size() (width, height float64)
- func (c *OffscreenCanvas) WasmDrawSource() (src Source)
- type Options
- type Source
Constants ¶
const ErrorElementNotCanvas = "element is not a canvas"
const ErrorNoCanvasFound = "no canvas found"
const ErrorSelectorNoCanvasFound = "querySelectorAll returned no canvas elements"
const ErrorSelectorNotCanvas = "querySelectorAll returned an element that is not a canvas"
const ErrorSelectorNotFound = "querySelectorAll returned null or undefined"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CanvasElement ¶
type CanvasElement struct {
// contains filtered or unexported fields
}
func GetCanvasById ¶
func GetCanvasById(id string, opts *Options) (canvas *CanvasElement, err error)
func QuerySelector ¶
func QuerySelector(selector string, opts *Options) (canvas *CanvasElement, err error)
func QuerySelectorAll ¶
func QuerySelectorAll(selector string, opts *Options) (canvases []*CanvasElement, err error)
func (*CanvasElement) AddEventListener ¶
func (c *CanvasElement) AddEventListener(eventType EventType, handler EventHandler) (handle *EventHandlerHandle)
func (*CanvasElement) ElementSize ¶
func (c *CanvasElement) ElementSize() (width, height float64)
Returns the size of the canvas element in the DOM (the size of the canvas element as it is displayed on the page).
func (*CanvasElement) GetContext ¶
func (*CanvasElement) RemoveEventListener ¶
func (c *CanvasElement) RemoveEventListener(handle *EventHandlerHandle)
func (*CanvasElement) Revision ¶
func (c *CanvasElement) Revision() (revision uint64)
Revision changes whenever assigning the canvas size resets its rendering context.
func (*CanvasElement) Size ¶
func (c *CanvasElement) Size() (width, height float64)
Returns the size of the canvas's drawing surface (the size of the canvas's internal drawing buffer).
func (*CanvasElement) WasmDrawSource ¶
func (c *CanvasElement) WasmDrawSource() (src Source)
type CanvasImageSource ¶
type CanvasImageSource interface {
WasmDrawSource() Source
}
CanvasImageSource is implemented by objects accepted by Context.DrawImage.
type EventHandler ¶
type EventHandlerHandle ¶
type EventHandlerHandle struct {
// contains filtered or unexported fields
}
type FrameCallback ¶
type FrameCallback func(dt, width, height float64)
type FrameLoop ¶
type FrameLoop struct {
// contains filtered or unexported fields
}
func NewFrameLoop ¶
func NewFrameLoop(surface FrameSurface, callback FrameCallback) (loop *FrameLoop)
NewFrameLoop creates a reusable requestAnimationFrame lifecycle driver.
func (*FrameLoop) Dispose ¶
func (l *FrameLoop) Dispose()
Dispose stops the loop and releases its JavaScript callback.
func (*FrameLoop) GetMSPerFrame ¶
type FrameSurface ¶
type Image ¶
type Image struct {
Source Source
Complete bool
NaturalWidth, NaturalHeight float64
OnLoad func()
OnError func(error)
// contains filtered or unexported fields
}
Image wraps HTMLImageElement without copying decoded pixels into WASM.
func (*Image) Close ¶
func (i *Image) Close()
Close detaches browser callbacks held by the image wrapper. It does not cancel a request that the browser has already started.
func (*Image) SetCrossOrigin ¶
func (*Image) WasmDrawSource ¶
type ImageBitmap ¶
type ImageBitmap struct {
Source Source
Width, Height float64
OnLoad func()
OnError func(error)
// contains filtered or unexported fields
}
ImageBitmap wraps a decoded browser ImageBitmap.
func LoadImageBitmap ¶
func LoadImageBitmap(src string) (bitmap *ImageBitmap)
func (*ImageBitmap) Close ¶
func (b *ImageBitmap) Close()
func (*ImageBitmap) WasmDrawSource ¶
func (b *ImageBitmap) WasmDrawSource() (src Source)
type OffscreenCanvas ¶
type OffscreenCanvas struct {
// contains filtered or unexported fields
}
func NewOffscreenCanvas ¶
func NewOffscreenCanvas(width, height float64) (offscreen *OffscreenCanvas)
func (*OffscreenCanvas) GetContext ¶
func (*OffscreenCanvas) Revision ¶
func (c *OffscreenCanvas) Revision() (revision uint64)
func (*OffscreenCanvas) SetSize ¶
func (c *OffscreenCanvas) SetSize(width, height float64)
func (*OffscreenCanvas) SetSourcePreparation ¶
func (c *OffscreenCanvas) SetSourcePreparation(prepare func())
SetSourcePreparation installs work that must run before another renderer reads this canvas.
func (*OffscreenCanvas) Size ¶
func (c *OffscreenCanvas) Size() (width, height float64)
func (*OffscreenCanvas) WasmDrawSource ¶
func (c *OffscreenCanvas) WasmDrawSource() (src Source)
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func DefaultOptions ¶
func DefaultOptions() (o *Options)
func (*Options) WithAutoResize ¶
WithAutoResize sets whether the canvas element should automatically resize when the window is resized.
func (*Options) WithScale ¶
WithScale sets the scale of the canvas relating to the DOM size and the internal drawing buffer size. A scale of 1.0 means that the internal drawing buffer size is the same as the DOM size. A scale of 2.0 means that the internal drawing buffer size is twice the DOM size, which can be useful for high-DPI displays.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
example/src
command
|
|
|
path2d
Package path2d provides retained canvas paths with an API mirroring the browser's Path2D object.
|
Package path2d provides retained canvas paths with an API mirroring the browser's Path2D object. |
|
internal
|
|
|
example/src
command
|
|
|
example/src
command
|