ssvg

package
v0.0.0-...-692212b Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: Apache-2.0 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 (this *Circle) Range(xmin, xmax, ymin, ymax *float64)

func (*Circle) Write

func (this *Circle) Write(w io.Writer, svg *Svg)

type Element

type Element interface {
	Write(w io.Writer, svg *Svg)
	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 (this *Ellipse) Range(xmin, xmax, ymin, ymax *float64)

func (*Ellipse) Write

func (this *Ellipse) Write(w io.Writer, svg *Svg)

type Frame

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

func (*Frame) Add

func (this *Frame) Add(e Element)

func (*Frame) Range1

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

func (*Frame) Range2

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

type HLine

type HLine struct {
	Y float64
	Style
}

func (*HLine) Range

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

func (*HLine) Write

func (this *HLine) Write(w io.Writer, svg *Svg)

type Icon

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

简易图标, 大小是固定的

func (*Icon) Range

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

func (*Icon) Write

func (this *Icon) Write(w io.Writer, svg *Svg)

type Line

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

func (*Line) Range

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

func (*Line) Write

func (this *Line) Write(w io.Writer, svg *Svg)

type Point

type Point struct {
	X, Y float64
}

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

type Polygon

type Polygon struct {
	Points []Point
	Style
}

func (*Polygon) Range

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

func (*Polygon) Write

func (this *Polygon) Write(w io.Writer, svg *Svg)

type Polyline

type Polyline struct {
	Points []Point
	Style
}

func (*Polyline) Range

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

func (*Polyline) Write

func (this *Polyline) Write(w io.Writer, svg *Svg)

type Rect

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

func (*Rect) Range

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

func (*Rect) Write

func (this *Rect) Write(w io.Writer, svg *Svg)

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)

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 (this *Svg) Add(e Element)

func (*Svg) CurrentFrame

func (this *Svg) CurrentFrame() *Frame
func (this *Svg) KeepLastFrameVisible() {
	this.CurrentFrame().KeepVisible = true
}

func (*Svg) NextFrame

func (this *Svg) NextFrame() *Frame

func (*Svg) Write

func (this *Svg) Write(w io.Writer, canvasPixelSize float64)

func (*Svg) WriteFile

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

, file);

type Text

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

func (*Text) Range

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

func (*Text) Write

func (this *Text) Write(w io.Writer, svg *Svg)

type VLine

type VLine struct {
	X float64
	Style
}

func (*VLine) Range

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

func (*VLine) Write

func (this *VLine) Write(w io.Writer, svg *Svg)

Jump to

Keyboard shortcuts

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