ssvg

package
v0.0.0-...-b05aa3b Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ssvg is for generate simple SVG, support muti-frame animation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultColors

func DefaultColors(index int) string

DefaultColors is easy way to choose color for serial of items. index can be any nonnegative integer.

Types

type Circle

type Circle struct {
	Cx, Cy, R float64
	Style
}

func (*Circle) Range

func (cr *Circle) Range(xmin, xmax, ymin, ymax *float64)

func (*Circle) Write

func (cr *Circle) Write(w io.Writer, svg *Svg) (err error)

type Element

type Element interface {
	Write(w io.Writer, svg *Svg) error
	Range(xmin, xmax, ymin, ymax *float64)
}

Element is abstract element.

type Ellipse

type Ellipse struct {
	Cx, Cy, Rx, Ry float64
	Style
}

func (*Ellipse) Range

func (el *Ellipse) Range(xmin, xmax, ymin, ymax *float64)

func (*Ellipse) Write

func (el *Ellipse) Write(w io.Writer, svg *Svg) (err error)

type Frame

type Frame struct {
	Elements    []Element
	Duration    int // 毫秒
	KeepVisible bool
}

func (*Frame) Add

func (frm *Frame) Add(e Element)

func (*Frame) Range1

func (frm *Frame) Range1(xmin, xmax, ymin, ymax *float64)

func (*Frame) Range2

func (frm *Frame) Range2(xmin, xmax, ymin, ymax *float64)

type HLine

type HLine struct {
	Y float64
	Style
}

func (*HLine) Range

func (hl *HLine) Range(xmin, xmax, ymin, ymax *float64)

func (*HLine) Write

func (hl *HLine) Write(w io.Writer, svg *Svg) (err error)

type Icon

type Icon struct {
	X, Y  float64
	Shape string  // "box", "circle"
	Zoom  float64 // 0 ~ 1.0
	Style
}

简易图标, 大小是固定的

func (*Icon) Range

func (icon *Icon) Range(xmin, xmax, ymin, ymax *float64)

func (*Icon) Write

func (icon *Icon) Write(w io.Writer, svg *Svg) (err error)

type Line

type Line struct {
	X1, Y1, X2, Y2 float64
	AuxLeft        bool // 左侧辅助线
	AuxRight       bool // 右侧辅助线
	Arrow          bool // 箭头
	Style
}

func (*Line) Range

func (line *Line) Range(xmin, xmax, ymin, ymax *float64)

func (*Line) Write

func (line *Line) Write(w io.Writer, svg *Svg) (err error)

type Point

type Point struct {
	X, Y float64
}

折线等元素中的点, 如需"点状图元"请用Icon

type Polygon

type Polygon struct {
	Points []Point
	Style
}

func (*Polygon) Range

func (ply *Polygon) Range(xmin, xmax, ymin, ymax *float64)

func (*Polygon) Write

func (ply *Polygon) Write(w io.Writer, svg *Svg) (err error)

type Polyline

type Polyline struct {
	Points []Point
	Style
}

func (*Polyline) Range

func (ply *Polyline) Range(xmin, xmax, ymin, ymax *float64)

func (*Polyline) Write

func (ply *Polyline) Write(w io.Writer, svg *Svg) (err error)

type Rect

type Rect struct {
	X, Y, W, H float64
	Style
}

func (*Rect) Range

func (rect *Rect) Range(xmin, xmax, ymin, ymax *float64)

func (*Rect) Write

func (rect *Rect) Write(w io.Writer, svg *Svg) (err error)

type Style

type Style struct {
	// Fill color
	FillColor string

	// Stroke color
	StrokeColor string

	// Stroke width in millimetres, 0 is treat as 1
	StrokeWidth float64

	// Transparent level between 0~1, opposite to opacity.
	Transparency float64
}

Style keep styles for element.

func (*Style) Write

func (style *Style) Write(w io.Writer, svg *Svg) (err error)

Write style attributes to w, for svg.

type Svg

type Svg struct {
	CanvasSize int // pixels

	Frames []*Frame

	YDown bool

	FrameDuration int // default frame duration
	// contains filtered or unexported fields
}

func (*Svg) Add

func (svb *Svg) Add(e Element)

func (*Svg) CurrentFrame

func (svg *Svg) CurrentFrame() *Frame

func (*Svg) NextFrame

func (svg *Svg) NextFrame() *Frame

func (*Svg) Write

func (svg *Svg) Write(w io.Writer, canvasPixelSize float64) (err error)

func (*Svg) WriteFile

func (svg *Svg) WriteFile(filename string, canvasPixelSize float64) (err error)

type Text

type Text struct {
	X, Y float64
	Text string
	Zoom float64
	Style
}

func (*Text) Range

func (txt *Text) Range(xmin, xmax, ymin, ymax *float64)

func (*Text) Write

func (txt *Text) Write(w io.Writer, svg *Svg) (err error)

type VLine

type VLine struct {
	X float64
	Style
}

func (*VLine) Range

func (vl *VLine) Range(xmin, xmax, ymin, ymax *float64)

func (*VLine) Write

func (vl *VLine) Write(w io.Writer, svg *Svg) (err error)

Jump to

Keyboard shortcuts

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