Documentation
¶
Index ¶
- Variables
- type Canvas
- func (c *Canvas) Clear(r Rectangle)
- func (c *Canvas) Height() float64
- func (c *Canvas) MeasureText(text string) (tm TextMetrics)
- func (c *Canvas) Path(p func(*PathBuilder)) Object
- func (c *Canvas) Rect(r Rectangle) Object
- func (c *Canvas) Text(text string, mw float64) Object
- func (c *Canvas) Width() float64
- type Font
- type LineCap
- type LineJoin
- type Object
- type PathBuilder
- type Point
- type Rectangle
- type TextMetrics
- func (tm TextMetrics) ActualBoundingBoxAscent() float64
- func (tm TextMetrics) ActualBoundingBoxDescent() float64
- func (tm TextMetrics) ActualBoundingBoxLeft() float64
- func (tm TextMetrics) ActualBoundingBoxRight() float64
- func (tm TextMetrics) AlphabeticBaseline() float64
- func (tm TextMetrics) EmHeightAscent() float64
- func (tm TextMetrics) EmHeightDescent() float64
- func (tm TextMetrics) FontBoundingBoxAscent() float64
- func (tm TextMetrics) FontBoundingBoxDescent() float64
- func (tm TextMetrics) HangingBaseline() float64
- func (tm TextMetrics) IdeographicBaseline() float64
- func (tm TextMetrics) Width() float64
Constants ¶
This section is empty.
Variables ¶
var ZP = Point{}
var ZR = Rectangle{}
Functions ¶
This section is empty.
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
Canvas represents an HTML <canvas> element and its associated 2D rendering context.
func New ¶
New returns a new Canvas that wraps the <canvas> elem. This will most likely be retrieved using
js.Global.Get("document").Call("getElementById", id)
If the browser doesn't support CanvasRenderingContext2D, an error is returned.
func (*Canvas) MeasureText ¶
func (c *Canvas) MeasureText(text string) (tm TextMetrics)
MeasureText returns a TextMetrics containing information about the string text.
func (*Canvas) Path ¶
func (c *Canvas) Path(p func(*PathBuilder)) Object
Path returns an Object that draws a path build by the function p. For more information, see the documentation for PathBuilder.
type Object ¶
type Object interface { // Stroke draws an outline of the Object. Stroke(Point) // Fill fills the area of the canvas represented by the Object. Fill(Point) // Set various styles having to do with drawing lines. For more // information, see the CanvasRenderingContext2D documentation. SetLineWidth(float64) SetLineCap(LineCap) SetLineJoin(LineJoin) SetMiterLimit(float64) SetLineDash([]float64) }
Object represents an object that can be drawn on the canvas.
type PathBuilder ¶
type PathBuilder struct {
// contains filtered or unexported fields
}
PathBuilder is a type that is passed to a function used to create a custom, path-based object. See the documentation for (*Canvas).Path().
func (PathBuilder) Arc ¶
func (pb PathBuilder) Arc(c Point, r float64, sa, ea float64, cc bool)
Add an arc to the path.
func (PathBuilder) Bezier ¶
func (pb PathBuilder) Bezier(cp1, cp2, end Point)
Add a bezier curve to the path.
func (PathBuilder) Line ¶
func (pb PathBuilder) Line(p Point)
Add a line from the current position to p to the path.
func (PathBuilder) Quadratic ¶
func (pb PathBuilder) Quadratic(cp, end Point)
Add a quadratic curve to the path.
type Point ¶
type Point struct {
X, Y float64
}
Point represents a point on the cartesian plane. It is patterned after image.Point, but is float64 based.
type Rectangle ¶
type Rectangle struct {
Min, Max Point
}
Rectangle represents a rectangle. It is patterned after image.Rectangle, but is float64 based.
type TextMetrics ¶
type TextMetrics struct {
// contains filtered or unexported fields
}
func (TextMetrics) ActualBoundingBoxAscent ¶
func (tm TextMetrics) ActualBoundingBoxAscent() float64
func (TextMetrics) ActualBoundingBoxDescent ¶
func (tm TextMetrics) ActualBoundingBoxDescent() float64
func (TextMetrics) ActualBoundingBoxLeft ¶
func (tm TextMetrics) ActualBoundingBoxLeft() float64
func (TextMetrics) ActualBoundingBoxRight ¶
func (tm TextMetrics) ActualBoundingBoxRight() float64
func (TextMetrics) AlphabeticBaseline ¶
func (tm TextMetrics) AlphabeticBaseline() float64
func (TextMetrics) EmHeightAscent ¶
func (tm TextMetrics) EmHeightAscent() float64
func (TextMetrics) EmHeightDescent ¶
func (tm TextMetrics) EmHeightDescent() float64
func (TextMetrics) FontBoundingBoxAscent ¶
func (tm TextMetrics) FontBoundingBoxAscent() float64
func (TextMetrics) FontBoundingBoxDescent ¶
func (tm TextMetrics) FontBoundingBoxDescent() float64
func (TextMetrics) HangingBaseline ¶
func (tm TextMetrics) HangingBaseline() float64
func (TextMetrics) IdeographicBaseline ¶
func (tm TextMetrics) IdeographicBaseline() float64
func (TextMetrics) Width ¶
func (tm TextMetrics) Width() float64