Documentation
¶
Rendered for js/wasm
Index ¶
- Constants
- type CanvasGradient
- type CanvasPattern
- type ColorSpace
- type Context
- func (c *Context) Arc(x, y, radius, startAngle, endAngle float64, counterclockwise ...bool) (self *Context)
- func (c *Context) ArcTo(x1, y1, x2, y2, radius float64) (self *Context)
- func (c *Context) BeginPath() (self *Context)
- func (c *Context) BezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y float64) (self *Context)
- func (c *Context) ClearRect(x, y, width, height float64) (self *Context)
- func (c *Context) Clip(fillRule ...string) (self *Context)
- func (c *Context) ClipPath(path *path2d.Path2D, fillRule ...string) (self *Context)
- func (c *Context) ClosePath() (self *Context)
- func (c *Context) CreateConicGradient(startAngle, x, y float64) (gradient *CanvasGradient)
- func (c *Context) CreateImageData(width, height float64) (imgData *ImageData)
- func (c *Context) CreateImageDataFrom(image *ImageData) (imgData *ImageData)
- func (c *Context) CreateLinearGradient(x0, y0, x1, y1 float64) (gradient *CanvasGradient)
- func (c *Context) CreatePattern(source wasmdraw.CanvasImageSource, repetition string) (pattern *CanvasPattern, err error)
- func (c *Context) CreateRadialGradient(x0, y0, r0, x1, y1, r1 float64) (gradient *CanvasGradient)
- func (c *Context) Dispose()
- func (c *Context) DrawImage(source wasmdraw.CanvasImageSource, args ...float64) (self *Context)
- func (c *Context) Ellipse(x, y, rx, ry, rotation, startAngle, endAngle float64, counterclockwise ...bool) (self *Context)
- func (c *Context) Fill(paths ...*path2d.Path2D) (self *Context)
- func (c *Context) FillPath(path *path2d.Path2D, fillRule ...string) (self *Context)
- func (c *Context) FillRect(x, y, width, height float64) (self *Context)
- func (c *Context) FillText(text string, x, y float64, maxWidth ...float64) (self *Context)
- func (c *Context) FillWithRule(fillRule string) (self *Context)
- func (c *Context) GetContextAttributes() (attributes ContextAttributes)
- func (c *Context) GetFPS() (fps int)
- func (c *Context) GetImageData(sx, sy, sw, sh float64) (imgData *ImageData)
- func (c *Context) GetLineDash() (dash []float64)
- func (c *Context) GetMSPerFrame() (mean, min, max float64)
- func (c *Context) GetTransform() (matrix DOMMatrix)
- func (c *Context) IsContextLost() (isLost bool)
- func (c *Context) IsPointInPath(x, y float64, fillRule ...string) (inPath bool)
- func (c *Context) IsPointInPath2D(path *path2d.Path2D, x, y float64, fillRule ...string) (inPath bool)
- func (c *Context) IsPointInStroke(x, y float64) (inStroke bool)
- func (c *Context) IsPointInStrokePath(path *path2d.Path2D, x, y float64) (inStroke bool)
- func (c *Context) LineTo(x, y float64) (self *Context)
- func (c *Context) MeasureText(text string) (metrics TextMetrics)
- func (c *Context) MoveTo(x, y float64) (self *Context)
- func (c *Context) PutImageData(image *ImageData, dx, dy float64, dirty ...float64) (ctx *Context)
- func (c *Context) QuadraticCurveTo(cpx, cpy, x, y float64) (self *Context)
- func (c *Context) Rect(x, y, width, height float64) (self *Context)
- func (c *Context) Reset() (self *Context)
- func (c *Context) ResetTransform() (self *Context)
- func (c *Context) Restore() (self *Context)
- func (c *Context) Rotate(angle float64) (self *Context)
- func (c *Context) RoundRect(x, y, width, height, radius float64) (self *Context)
- func (c *Context) Save() (self *Context)
- func (c *Context) Scale(x, y float64) (self *Context)
- func (c *Context) SetLineDash(segments []float64) (self *Context)
- func (c *Context) SetTransform(a, b, cc, d, e, f float64) (self *Context)
- func (c *Context) Start() (self *Context)
- func (c *Context) Stop() (self *Context)
- func (c *Context) Stroke(paths ...*path2d.Path2D) (self *Context)
- func (c *Context) StrokeRect(x, y, width, height float64) (self *Context)
- func (c *Context) StrokeText(text string, x, y float64, maxWidth ...float64) (self *Context)
- func (c *Context) Transform(a, b, cc, d, e, f float64) (self *Context)
- func (c *Context) Translate(x, y float64) (self *Context)
- type ContextAttributes
- type DOMMatrix
- type ImageData
- type Options
- func (o *Options) WithAlpha(alpha bool) (self *Options)
- func (o *Options) WithColorSpace(colorSpace ColorSpace) (self *Options)
- func (o *Options) WithCommandCapacity(bytes int) (self *Options)
- func (o *Options) WithDesynchronized(desynchronized bool) (self *Options)
- func (o *Options) WithWillReadFrequently(willReadFrequently bool) (self *Options)
- type TextMetrics
Constants ¶
View Source
const ( TextAlignLeft = "left" TextAlignRight = "right" TextAlignCenter = "center" TextAlignStart = "start" TextAlignEnd = "end" TextBaselineTop = "top" TextBaselineHanging = "hanging" TextBaselineMiddle = "middle" TextBaselineAlphabetic = "alphabetic" TextBaselineIdeographic = "ideographic" TextBaselineBottom = "bottom" DirectionInherit = "inherit" DirectionLTR = "ltr" DirectionRTL = "rtl" LineCapButt = "butt" LineCapRound = "round" LineCapSquare = "square" LineJoinRound = "round" LineJoinBevel = "bevel" LineJoinMiter = "miter" FillRuleNonZero = "nonzero" FillRuleEvenOdd = "evenodd" ImageSmoothingQualityLow = "low" ImageSmoothingQualityMedium = "medium" ImageSmoothingQualityHigh = "high" )
View Source
const ErrorNoContextFound = "failed to get 2D context from canvas"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CanvasGradient ¶
type CanvasGradient struct {
// contains filtered or unexported fields
}
func (*CanvasGradient) AddColorStop ¶
func (g *CanvasGradient) AddColorStop(offset float64, color string) (gradient *CanvasGradient)
type CanvasPattern ¶
type CanvasPattern struct {
// contains filtered or unexported fields
}
func (*CanvasPattern) SetTransform ¶
func (p *CanvasPattern) SetTransform(matrix DOMMatrix) (pattern *CanvasPattern)
type ColorSpace ¶
type ColorSpace string
const ( ColorSpaceSRGB ColorSpace = "srgb" ColorSpaceDisplayP3 ColorSpace = "display-p3" )
type Context ¶
type Context struct {
// Settable properties
FillStyle any
StrokeStyle any
LineWidth float64
GlobalAlpha float64
Font string
Direction string
Filter string
FontKerning string
FontStretch string
FontVariantCaps string
GlobalCompositeOperation string
ImageSmoothingEnabled bool
ImageSmoothingQuality string
LetterSpacing string
LineCap string
LineDashOffset float64
LineJoin string
MiterLimit float64
ShadowBlur float64
ShadowColor string
ShadowOffsetX float64
ShadowOffsetY float64
TextAlign string
TextBaseline string
TextRendering string
WordSpacing string
// OnFrame is called by requestAnimationFrame. dt is measured in seconds.
// The command buffer is submitted automatically when it returns.
OnFrame func(dt, width, height float64)
// contains filtered or unexported fields
}
func GetContext ¶
func GetContext(canvas *wasmdraw.CanvasElement, opts *Options) (ctx *Context, err error)
func GetOffscreenContext ¶
func GetOffscreenContext(canvas *wasmdraw.OffscreenCanvas, opts *Options) (ctx *Context, err error)
func (*Context) BezierCurveTo ¶
func (*Context) CreateConicGradient ¶
func (c *Context) CreateConicGradient(startAngle, x, y float64) (gradient *CanvasGradient)
func (*Context) CreateImageData ¶
func (*Context) CreateImageDataFrom ¶
func (*Context) CreateLinearGradient ¶
func (c *Context) CreateLinearGradient(x0, y0, x1, y1 float64) (gradient *CanvasGradient)
func (*Context) CreatePattern ¶
func (c *Context) CreatePattern(source wasmdraw.CanvasImageSource, repetition string) (pattern *CanvasPattern, err error)
func (*Context) CreateRadialGradient ¶
func (c *Context) CreateRadialGradient(x0, y0, r0, x1, y1, r1 float64) (gradient *CanvasGradient)
func (*Context) DrawImage ¶
func (c *Context) DrawImage(source wasmdraw.CanvasImageSource, args ...float64) (self *Context)
DrawImage mirrors CanvasRenderingContext2D.drawImage. After the source, valid coordinate counts are 2, 4, and 8.
func (*Context) FillWithRule ¶
func (*Context) GetContextAttributes ¶
func (c *Context) GetContextAttributes() (attributes ContextAttributes)
func (*Context) GetImageData ¶
func (*Context) GetLineDash ¶
func (*Context) GetMSPerFrame ¶
func (*Context) GetTransform ¶
func (*Context) IsContextLost ¶
func (*Context) IsPointInPath ¶
func (*Context) IsPointInPath2D ¶
func (*Context) IsPointInStroke ¶
func (*Context) IsPointInStrokePath ¶
func (*Context) MeasureText ¶
func (c *Context) MeasureText(text string) (metrics TextMetrics)
MeasureText is a synchronization point: queued commands are submitted so the browser measures with the exact current canvas state.
func (*Context) PutImageData ¶
func (*Context) QuadraticCurveTo ¶
func (*Context) Reset ¶
Reset mirrors context.reset and restores drawing state, transforms, paths, and clipping to their defaults.
func (*Context) ResetTransform ¶
func (*Context) SetLineDash ¶
func (*Context) SetTransform ¶
func (*Context) StrokeRect ¶
func (*Context) StrokeText ¶
type ContextAttributes ¶
type ImageData ¶
type ImageData struct {
Width, Height int
// contains filtered or unexported fields
}
func (*ImageData) Close ¶
func (i *ImageData) Close()
Close releases executor references to this browser-owned pixel buffer.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func DefaultOptions ¶
func DefaultOptions() (o *Options)
func (*Options) WithColorSpace ¶
func (o *Options) WithColorSpace(colorSpace ColorSpace) (self *Options)
func (*Options) WithCommandCapacity ¶
func (*Options) WithDesynchronized ¶
func (*Options) WithWillReadFrequently ¶
type TextMetrics ¶
type TextMetrics struct {
Width float64
ActualBoundingBoxLeft float64
ActualBoundingBoxRight float64
ActualBoundingBoxAscent float64
ActualBoundingBoxDescent float64
FontBoundingBoxAscent float64
FontBoundingBoxDescent float64
EmHeightAscent float64
EmHeightDescent float64
HangingBaseline float64
AlphabeticBaseline float64
IdeographicBaseline float64
}
Click to show internal directories.
Click to hide internal directories.