svg

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Circle

type Circle struct {
	Element
}

Circle is an SVG circle element.

func NewCircle

func NewCircle(r int) *Circle

NewCircle creates a detached SVG circle with a given radius.

func (*Circle) Fill

func (c *Circle) Fill(cl dom.Color)

func (*Circle) SetPos

func (c *Circle) SetPos(x, y int)

func (*Circle) SetR

func (c *Circle) SetR(r int)

func (*Circle) Stroke

func (c *Circle) Stroke(cl dom.Color)

type Container

type Container struct {
	Element
}

Container is a common base for SVG elements that can contain other elements.

func NewContainer

func NewContainer(tag string) *Container

NewContainer creates an SVG element that provides container-like API (like "g").

func (*Container) NewCircle

func (c *Container) NewCircle(r int) *Circle

NewCircle creates an SVG circle with a given radius in this container.

func (*Container) NewG

func (c *Container) NewG() *G

NewG creates an SVG group element ("g") in this container.

func (*Container) NewLine

func (c *Container) NewLine() *Line

NewLine creates an SVG line in this container.

func (*Container) NewRect

func (c *Container) NewRect(w, h int) *Rect

NewRect creates an SVG rectangle with a given size in this container.

func (*Container) NewText

func (c *Container) NewText(str string) *Text

NewText creates an SVG text element in this container.

type Element

type Element struct {
	// contains filtered or unexported fields
}

Element is a common base for SVG elements.

func NewElement

func NewElement(tag string) *Element

NewElement creates a new SVG element.

func (*Element) DOMElement

func (e *Element) DOMElement() *dom.Element

DOMElement returns a dom.Element associated with this SVG element.

func (*Element) OnClick

func (e *Element) OnClick(h dom.MouseEventHandler)

OnClick registers an onclick event listener.

func (*Element) OnMouseDown

func (e *Element) OnMouseDown(h dom.MouseEventHandler)

OnMouseDown registers an onmousedown event listener.

func (*Element) OnMouseMove

func (e *Element) OnMouseMove(h dom.MouseEventHandler)

OnMouseMove registers an onmousemove event listener.

func (*Element) OnMouseUp

func (e *Element) OnMouseUp(h dom.MouseEventHandler)

OnMouseUp registers an onmouseup event listener.

func (*Element) SetAttribute

func (e *Element) SetAttribute(k string, v interface{})

SetAttribute sets an attribute of SVG element.

func (*Element) Style

func (e *Element) Style() *dom.Style

Style returns a style object for this element.

func (*Element) Transform

func (e *Element) Transform(arr ...Transform)

Transform sets a list of transformations for SVG element. It will override an old value.

func (*Element) Translate

func (e *Element) Translate(x, y float64)

Translate sets an SVG element transform to translation. It will override an old transform value.

type G

type G struct {
	Container
}

G is an SVG group element.

func NewG

func NewG() *G

NewG creates a detached SVG group element ("g").

type Line

type Line struct {
	Element
}

Line is an SVG line element.

func NewLine

func NewLine() *Line

NewLine creates a detached SVG line.

func (*Line) SetPos

func (l *Line) SetPos(p1, p2 dom.Point)

func (*Line) SetPos1

func (l *Line) SetPos1(p dom.Point)

func (*Line) SetPos2

func (l *Line) SetPos2(p dom.Point)

func (*Line) SetStrokeWidth

func (l *Line) SetStrokeWidth(w float64)

type Rect

type Rect struct {
	Element
}

Rect is an SVG rectangle element.

func NewRect

func NewRect(w, h int) *Rect

NewRect creates a detached SVG rectangle with a given size.

func (*Rect) Fill

func (c *Rect) Fill(cl dom.Color)

func (*Rect) SetPos

func (c *Rect) SetPos(x, y int)

func (*Rect) SetRound

func (c *Rect) SetRound(rx, ry int)

func (*Rect) SetSize

func (c *Rect) SetSize(w, h int)

func (*Rect) Stroke

func (c *Rect) Stroke(cl dom.Color)

type Rotate

type Rotate struct {
	A float64
}

Rotate rotates an element relative to the parent.

func (Rotate) TransformString

func (t Rotate) TransformString() string

type RotatePt

type RotatePt struct {
	A, X, Y float64
}

RotatePt rotates an element relative a point.

func (RotatePt) TransformString

func (t RotatePt) TransformString() string

type SVG

type SVG struct {
	Container
}

SVG is a root SVG element.

func New

func New(w, h dom.Unit) *SVG

New creates a new root SVG element with a given size.

func NewFullscreen

func NewFullscreen() *SVG

NewFullscreen is like New, but the resulting element will try to fill the whole client area.

type Scale

type Scale struct {
	X, Y float64
}

Scale scales an element.

func (Scale) TransformString

func (t Scale) TransformString() string

type Text

type Text struct {
	Element
}

Text is an SVG text element.

func NewText

func NewText(str string) *Text

NewText creates a detached SVG text element.

func (*Text) Selectable

func (t *Text) Selectable(v bool)

func (*Text) SetDPos

func (t *Text) SetDPos(dx, dy dom.Unit)

func (*Text) SetPos

func (t *Text) SetPos(x, y int)

func (*Text) SetText

func (t *Text) SetText(s string)

type Transform

type Transform interface {
	TransformString() string
}

Transform is transformation that can be applied to SVG elements.

type Translate

type Translate struct {
	X, Y float64
}

Translate moves an element.

func (Translate) TransformString

func (t Translate) TransformString() string

Jump to

Keyboard shortcuts

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