Documentation
¶
Overview ¶
Package canvas provides helpers for the plugin canvas stream protocol.
Index ¶
- Constants
- Variables
- func WriteFrame(w io.Writer, frame Frame) error
- type Announce
- type AnnounceMode
- type Arc
- type BezierCurve
- type Circle
- type Clear
- type Clip
- type Command
- type CommandType
- type CompositeOperation
- type Cursor
- type Ellipse
- type Event
- type EventType
- type FillRule
- type FillText
- type FocusRegion
- type Frame
- type Gradient
- type GradientKind
- type GradientStop
- type Image
- type ImageData
- type KeyEvent
- type Line
- type LineCap
- type LineDash
- type LineJoin
- type MeasureText
- type ModifierState
- type Paint
- type PanelTheme
- type Path
- type Pattern
- type Point
- type PointerEvent
- type Polygon
- type Polyline
- type QuadraticCurve
- type Radii
- type RawCommand
- type ReadyEvent
- type Rect
- type Region
- type RegionOption
- type RegionShape
- type Regions
- type ResetStyle
- type ResetTransform
- type ResizeEvent
- type Restore
- type Rotate
- type Save
- type Scale
- type Set
- type Shadow
- type Snapshot
- type SnapshotEvent
- type StrokeText
- type Style
- type Text
- type TextAlign
- type TextBaseline
- type TextBox
- type TextMetricsEvent
- type TextVerticalAlign
- type Transform
- type Translate
- type WheelEvent
Constants ¶
View Source
const ( PanelThemeLight = plugin.PanelThemeLight PanelThemeDark = plugin.PanelThemeDark )
View Source
const ( PointerDown = "pointerdown" PointerMove = "pointermove" PointerUp = "pointerup" PointerCancel = "pointercancel" )
Variables ¶
View Source
var ErrInvalidInput = plugin.ErrInvalidInput
Functions ¶
Types ¶
type Announce ¶
type Announce struct {
Text string `json:"text,omitempty"`
Mode AnnounceMode `json:"mode,omitempty"`
}
func (Announce) MarshalJSON ¶
type AnnounceMode ¶
type AnnounceMode string
const ( AnnouncePolite AnnounceMode = "polite" AnnounceAssertive AnnounceMode = "assertive" )
type Arc ¶
type Arc struct {
Paint
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Radius float64 `json:"radius,omitempty"`
StartAngle float64 `json:"startAngle,omitempty"`
EndAngle float64 `json:"endAngle,omitempty"`
CounterClockwise bool `json:"counterclockwise,omitempty"`
}
func (Arc) MarshalJSON ¶
type BezierCurve ¶
type BezierCurve struct {
Paint
X0 float64 `json:"x0,omitempty"`
Y0 float64 `json:"y0,omitempty"`
CP1X float64 `json:"cp1x,omitempty"`
CP1Y float64 `json:"cp1y,omitempty"`
CP2X float64 `json:"cp2x,omitempty"`
CP2Y float64 `json:"cp2y,omitempty"`
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
}
func (BezierCurve) MarshalJSON ¶
func (c BezierCurve) MarshalJSON() ([]byte, error)
type Circle ¶
type Circle struct {
Paint
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Radius float64 `json:"radius,omitempty"`
}
func (Circle) MarshalJSON ¶
type Clear ¶
type Clear struct {
Color string `json:"color,omitempty"`
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Width float64 `json:"width,omitempty"`
Height float64 `json:"height,omitempty"`
}
func (Clear) MarshalJSON ¶
type Clip ¶
type Clip struct {
Shape RegionShape `json:"shape,omitempty"`
D string `json:"d,omitempty"`
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Width float64 `json:"width,omitempty"`
Height float64 `json:"height,omitempty"`
Radius float64 `json:"radius,omitempty"`
Radii *Radii `json:"radii,omitempty"`
Points []Point `json:"points,omitempty"`
FillRule FillRule `json:"fillRule,omitempty"`
}
func (Clip) MarshalJSON ¶
type CommandType ¶
type CommandType string
const ( CommandClear CommandType = "clear" CommandSet CommandType = "set" CommandRegions CommandType = "regions" CommandSave CommandType = "save" CommandRestore CommandType = "restore" CommandResetTransform CommandType = "resetTransform" CommandTranslate CommandType = "translate" CommandScale CommandType = "scale" CommandRotate CommandType = "rotate" CommandTransform CommandType = "transform" CommandStyle CommandType = "style" CommandResetStyle CommandType = "resetStyle" CommandLineDash CommandType = "lineDash" CommandShadow CommandType = "shadow" CommandGradient CommandType = "gradient" CommandPattern CommandType = "pattern" CommandClip CommandType = "clip" CommandRect CommandType = "rect" CommandLine CommandType = "line" CommandPolyline CommandType = "polyline" CommandPolygon CommandType = "polygon" CommandArc CommandType = "arc" CommandQuadraticCurve CommandType = "quadraticCurve" CommandBezierCurve CommandType = "bezierCurve" CommandCircle CommandType = "circle" CommandEllipse CommandType = "ellipse" CommandPath CommandType = "path" CommandText CommandType = "text" CommandFillText CommandType = "fillText" CommandStrokeText CommandType = "strokeText" CommandTextBox CommandType = "textBox" CommandMeasureText CommandType = "measureText" CommandImage CommandType = "image" CommandImageData CommandType = "imageData" CommandSnapshot CommandType = "snapshot" CommandCursor CommandType = "cursor" CommandFocusRegion CommandType = "focusRegion" CommandAnnounce CommandType = "announce" )
type CompositeOperation ¶
type CompositeOperation string
const ( CompositeSourceOver CompositeOperation = "source-over" CompositeSourceIn CompositeOperation = "source-in" CompositeSourceOut CompositeOperation = "source-out" CompositeSourceAtop CompositeOperation = "source-atop" CompositeDestinationOver CompositeOperation = "destination-over" CompositeDestinationIn CompositeOperation = "destination-in" CompositeDestinationOut CompositeOperation = "destination-out" CompositeDestinationAtop CompositeOperation = "destination-atop" CompositeLighter CompositeOperation = "lighter" CompositeCopy CompositeOperation = "copy" CompositeXOR CompositeOperation = "xor" CompositeMultiply CompositeOperation = "multiply" CompositeScreen CompositeOperation = "screen" CompositeOverlay CompositeOperation = "overlay" CompositeDarken CompositeOperation = "darken" CompositeLighten CompositeOperation = "lighten" CompositeColorDodge CompositeOperation = "color-dodge" CompositeColorBurn CompositeOperation = "color-burn" CompositeHardLight CompositeOperation = "hard-light" CompositeSoftLight CompositeOperation = "soft-light" CompositeDifference CompositeOperation = "difference" CompositeExclusion CompositeOperation = "exclusion" CompositeHue CompositeOperation = "hue" CompositeSaturation CompositeOperation = "saturation" CompositeColor CompositeOperation = "color" CompositeLuminosity CompositeOperation = "luminosity" )
type Cursor ¶
type Cursor struct {
Value string `json:"value,omitempty"`
}
func (Cursor) MarshalJSON ¶
type Ellipse ¶
type Ellipse struct {
Paint
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
RadiusX float64 `json:"radiusX,omitempty"`
RadiusY float64 `json:"radiusY,omitempty"`
Rotation float64 `json:"rotation,omitempty"`
}
func (Ellipse) MarshalJSON ¶
type Event ¶
type Event interface {
EventType() EventType
// contains filtered or unexported methods
}
func ParseEvent ¶
type FillText ¶
type FillText struct {
Paint
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Text string `json:"text,omitempty"`
MaxWidth *float64 `json:"maxWidth,omitempty"`
}
func (FillText) MarshalJSON ¶
type FocusRegion ¶
type FocusRegion struct {
ID string `json:"id,omitempty"`
}
func (FocusRegion) MarshalJSON ¶
func (c FocusRegion) MarshalJSON() ([]byte, error)
type Gradient ¶
type Gradient struct {
ID string `json:"id"`
Kind GradientKind `json:"kind"`
X0 float64 `json:"x0,omitempty"`
Y0 float64 `json:"y0,omitempty"`
X1 float64 `json:"x1,omitempty"`
Y1 float64 `json:"y1,omitempty"`
R0 float64 `json:"r0,omitempty"`
R1 float64 `json:"r1,omitempty"`
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
StartAngle float64 `json:"startAngle,omitempty"`
Stops []GradientStop `json:"stops,omitempty"`
}
func (Gradient) MarshalJSON ¶
type GradientKind ¶
type GradientKind string
const ( GradientLinear GradientKind = "linear" GradientRadial GradientKind = "radial" GradientConic GradientKind = "conic" )
type GradientStop ¶
type Image ¶
type Image struct {
Paint
Src string `json:"src,omitempty"`
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Width float64 `json:"width,omitempty"`
Height float64 `json:"height,omitempty"`
SourceX float64 `json:"sourceX,omitempty"`
SourceY float64 `json:"sourceY,omitempty"`
SourceWidth float64 `json:"sourceWidth,omitempty"`
SourceHeight float64 `json:"sourceHeight,omitempty"`
Smoothing *bool `json:"smoothing,omitempty"`
}
func (Image) MarshalJSON ¶
type ImageData ¶
type ImageData struct {
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Data []int `json:"data,omitempty"`
}
func (ImageData) MarshalJSON ¶
type KeyEvent ¶
type Line ¶
type Line struct {
Paint
X1 float64 `json:"x1,omitempty"`
Y1 float64 `json:"y1,omitempty"`
X2 float64 `json:"x2,omitempty"`
Y2 float64 `json:"y2,omitempty"`
}
func (Line) MarshalJSON ¶
type LineDash ¶
type LineDash struct {
Segments []float64 `json:"segments,omitempty"`
Offset float64 `json:"offset,omitempty"`
}
func (LineDash) MarshalJSON ¶
type MeasureText ¶
type MeasureText struct {
RequestID string `json:"requestId,omitempty"`
Text string `json:"text,omitempty"`
Font string `json:"font,omitempty"`
}
func (MeasureText) MarshalJSON ¶
func (c MeasureText) MarshalJSON() ([]byte, error)
type ModifierState ¶
type Paint ¶
type Paint struct {
Fill string `json:"fill,omitempty"`
Stroke string `json:"stroke,omitempty"`
LineWidth float64 `json:"lineWidth,omitempty"`
Font string `json:"font,omitempty"`
Alpha *float64 `json:"alpha,omitempty"`
Composite CompositeOperation `json:"composite,omitempty"`
LineCap LineCap `json:"lineCap,omitempty"`
LineJoin LineJoin `json:"lineJoin,omitempty"`
TextAlign TextAlign `json:"textAlign,omitempty"`
TextBaseline TextBaseline `json:"textBaseline,omitempty"`
FillID string `json:"fillId,omitempty"`
StrokeID string `json:"strokeId,omitempty"`
Filter string `json:"filter,omitempty"`
Direction string `json:"direction,omitempty"`
MiterLimit *float64 `json:"miterLimit,omitempty"`
NoFill bool `json:"-"`
NoStroke bool `json:"-"`
}
type PanelTheme ¶
type PanelTheme = plugin.PanelTheme
type Path ¶
type Path struct {
Paint
D string `json:"d,omitempty"`
FillRule FillRule `json:"fillRule,omitempty"`
}
func (Path) MarshalJSON ¶
type Pattern ¶
type Pattern struct {
ID string `json:"id"`
Src string `json:"src"`
Repetition string `json:"repetition,omitempty"`
}
func (Pattern) MarshalJSON ¶
type PointerEvent ¶
type PointerEvent struct {
Type EventType `json:"type"`
Event string `json:"event"`
X float64 `json:"x"`
Y float64 `json:"y"`
Button int `json:"button,omitempty"`
Buttons int `json:"buttons,omitempty"`
PointerID int `json:"pointerId,omitempty"`
PointerType string `json:"pointerType,omitempty"`
RegionID string `json:"regionId,omitempty"`
Modifiers ModifierState `json:"modifiers,omitempty"`
}
func (PointerEvent) EventType ¶
func (PointerEvent) EventType() EventType
type Polygon ¶
func (Polygon) MarshalJSON ¶
type Polyline ¶
func (Polyline) MarshalJSON ¶
type QuadraticCurve ¶
type QuadraticCurve struct {
Paint
X0 float64 `json:"x0,omitempty"`
Y0 float64 `json:"y0,omitempty"`
CPX float64 `json:"cpx,omitempty"`
CPY float64 `json:"cpy,omitempty"`
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
}
func (QuadraticCurve) MarshalJSON ¶
func (c QuadraticCurve) MarshalJSON() ([]byte, error)
type RawCommand ¶
type RawCommand struct {
Type CommandType `json:"type"`
Fields map[string]any `json:"-"`
}
func (RawCommand) MarshalJSON ¶
func (c RawCommand) MarshalJSON() ([]byte, error)
type ReadyEvent ¶
type ReadyEvent struct {
Type EventType `json:"type"`
Width float64 `json:"width"`
Height float64 `json:"height"`
ViewportWidth float64 `json:"viewportWidth,omitempty"`
ViewportHeight float64 `json:"viewportHeight,omitempty"`
Scale float64 `json:"scale,omitempty"`
DPR float64 `json:"dpr"`
Theme PanelTheme `json:"theme,omitempty"`
}
func (ReadyEvent) EventType ¶
func (ReadyEvent) EventType() EventType
type Rect ¶
type Rect struct {
Paint
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Width float64 `json:"width,omitempty"`
Height float64 `json:"height,omitempty"`
Radius float64 `json:"radius,omitempty"`
Radii *Radii `json:"radii,omitempty"`
}
func (Rect) MarshalJSON ¶
type Region ¶
type Region struct {
ID string `json:"id"`
Shape RegionShape `json:"shape,omitempty"`
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width,omitempty"`
Height float64 `json:"height,omitempty"`
Radius float64 `json:"radius,omitempty"`
Radii *Radii `json:"radii,omitempty"`
Points []Point `json:"points,omitempty"`
D string `json:"d,omitempty"`
Cursor string `json:"cursor,omitempty"`
Label string `json:"label,omitempty"`
CapturePointer bool `json:"capturePointer,omitempty"`
}
func CircleRegion ¶
func CircleRegion(id string, x, y, radius float64, opts ...RegionOption) Region
func PathRegion ¶
func PathRegion(id, d string, opts ...RegionOption) Region
func PolygonRegion ¶
func PolygonRegion(id string, points []Point, opts ...RegionOption) Region
func RectRegion ¶
func RectRegion(id string, x, y, width, height float64, opts ...RegionOption) Region
type RegionOption ¶
type RegionOption func(*Region)
func WithCapturePointer ¶
func WithCapturePointer() RegionOption
func WithCursor ¶
func WithCursor(cursor string) RegionOption
func WithLabel ¶
func WithLabel(label string) RegionOption
func WithRadii ¶
func WithRadii(radii Radii) RegionOption
func WithRadius ¶
func WithRadius(radius float64) RegionOption
type RegionShape ¶
type RegionShape string
const ( RegionRect RegionShape = "rect" RegionCircle RegionShape = "circle" RegionPolygon RegionShape = "polygon" RegionPath RegionShape = "path" )
type Regions ¶
type Regions struct {
Items []Region `json:"items,omitempty"`
}
func (Regions) MarshalJSON ¶
type ResetStyle ¶
type ResetStyle struct{}
func (ResetStyle) MarshalJSON ¶
func (c ResetStyle) MarshalJSON() ([]byte, error)
type ResetTransform ¶
type ResetTransform struct{}
func (ResetTransform) MarshalJSON ¶
func (c ResetTransform) MarshalJSON() ([]byte, error)
type ResizeEvent ¶
type ResizeEvent struct {
Type EventType `json:"type"`
Width float64 `json:"width"`
Height float64 `json:"height"`
ViewportWidth float64 `json:"viewportWidth,omitempty"`
ViewportHeight float64 `json:"viewportHeight,omitempty"`
Scale float64 `json:"scale,omitempty"`
DPR float64 `json:"dpr"`
Theme PanelTheme `json:"theme,omitempty"`
}
func (ResizeEvent) EventType ¶
func (ResizeEvent) EventType() EventType
type Rotate ¶
type Rotate struct {
Angle float64 `json:"angle,omitempty"`
}
func (Rotate) MarshalJSON ¶
type Scale ¶
func (Scale) MarshalJSON ¶
type Set ¶
type Set struct {
Background string `json:"background,omitempty"`
Cursor string `json:"cursor,omitempty"`
Regions []Region `json:"regions,omitempty"`
}
func (Set) MarshalJSON ¶
type Shadow ¶
type Shadow struct {
Color string `json:"color,omitempty"`
Blur float64 `json:"blur,omitempty"`
OffsetX float64 `json:"offsetX,omitempty"`
OffsetY float64 `json:"offsetY,omitempty"`
}
func (Shadow) MarshalJSON ¶
type Snapshot ¶
type Snapshot struct {
RequestID string `json:"requestId,omitempty"`
MIME string `json:"mime,omitempty"`
Quality float64 `json:"quality,omitempty"`
MinIntervalMs int `json:"minIntervalMs,omitempty"`
}
func (Snapshot) MarshalJSON ¶
type SnapshotEvent ¶
type SnapshotEvent struct {
Type EventType `json:"type"`
RequestID string `json:"requestId,omitempty"`
MIME string `json:"mime,omitempty"`
DataURL string `json:"dataUrl,omitempty"`
Width float64 `json:"width,omitempty"`
Height float64 `json:"height,omitempty"`
}
func (SnapshotEvent) EventType ¶
func (SnapshotEvent) EventType() EventType
type StrokeText ¶
type StrokeText struct {
Paint
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Text string `json:"text,omitempty"`
MaxWidth *float64 `json:"maxWidth,omitempty"`
}
func (StrokeText) MarshalJSON ¶
func (c StrokeText) MarshalJSON() ([]byte, error)
type Text ¶
type Text struct {
Paint
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Text string `json:"text,omitempty"`
MaxWidth *float64 `json:"maxWidth,omitempty"`
}
func (Text) MarshalJSON ¶
type TextBaseline ¶
type TextBaseline string
const ( TextBaselineTop TextBaseline = "top" TextBaselineHanging TextBaseline = "hanging" TextBaselineMiddle TextBaseline = "middle" TextBaselineAlphabetic TextBaseline = "alphabetic" TextBaselineIdeographic TextBaseline = "ideographic" TextBaselineBottom TextBaseline = "bottom" )
type TextBox ¶
type TextBox struct {
Paint
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Width float64 `json:"width,omitempty"`
Height float64 `json:"height,omitempty"`
LineHeight float64 `json:"lineHeight,omitempty"`
Padding float64 `json:"padding,omitempty"`
MaxLines int `json:"maxLines,omitempty"`
Ellipsis string `json:"ellipsis,omitempty"`
VerticalAlign TextVerticalAlign `json:"verticalAlign,omitempty"`
Background string `json:"background,omitempty"`
BackgroundID string `json:"backgroundId,omitempty"`
Radius float64 `json:"radius,omitempty"`
Radii *Radii `json:"radii,omitempty"`
Text string `json:"text,omitempty"`
}
func (TextBox) MarshalJSON ¶
type TextMetricsEvent ¶
type TextMetricsEvent struct {
Type EventType `json:"type"`
RequestID string `json:"requestId,omitempty"`
Text string `json:"text,omitempty"`
Width float64 `json:"width"`
ActualBoundingBoxLeft float64 `json:"actualBoundingBoxLeft,omitempty"`
ActualBoundingBoxRight float64 `json:"actualBoundingBoxRight,omitempty"`
ActualBoundingBoxAscent float64 `json:"actualBoundingBoxAscent,omitempty"`
ActualBoundingBoxDescent float64 `json:"actualBoundingBoxDescent,omitempty"`
FontBoundingBoxAscent float64 `json:"fontBoundingBoxAscent,omitempty"`
FontBoundingBoxDescent float64 `json:"fontBoundingBoxDescent,omitempty"`
EmHeightAscent float64 `json:"emHeightAscent,omitempty"`
EmHeightDescent float64 `json:"emHeightDescent,omitempty"`
HangingBaseline float64 `json:"hangingBaseline,omitempty"`
AlphabeticBaseline float64 `json:"alphabeticBaseline,omitempty"`
IdeographicBaseline float64 `json:"ideographicBaseline,omitempty"`
}
func (TextMetricsEvent) EventType ¶
func (TextMetricsEvent) EventType() EventType
type TextVerticalAlign ¶
type TextVerticalAlign string
const ( TextVerticalAlignTop TextVerticalAlign = "top" TextVerticalAlignMiddle TextVerticalAlign = "middle" TextVerticalAlignBottom TextVerticalAlign = "bottom" )
type Transform ¶
type Transform struct {
A float64 `json:"a"`
B float64 `json:"b"`
C float64 `json:"c"`
D float64 `json:"d"`
E float64 `json:"e"`
F float64 `json:"f"`
}
func (Transform) MarshalJSON ¶
type Translate ¶
func (Translate) MarshalJSON ¶
type WheelEvent ¶
type WheelEvent struct {
Type EventType `json:"type"`
X float64 `json:"x"`
Y float64 `json:"y"`
DeltaX float64 `json:"deltaX"`
DeltaY float64 `json:"deltaY"`
DeltaMode int `json:"deltaMode,omitempty"`
Modifiers ModifierState `json:"modifiers,omitempty"`
}
func (WheelEvent) EventType ¶
func (WheelEvent) EventType() EventType
Click to show internal directories.
Click to hide internal directories.