Documentation
¶
Overview ¶
高级动画构建器 / Advanced Animation Builder 提供简化的API来创建常见的动画效果 / Provides simplified API for creating common animation effects
Package svg provides a comprehensive SVG (Scalable Vector Graphics) library for Go svg包为Go提供了一个全面的SVG(可缩放矢量图形)库
Index ¶
- func ImageToJPEGBytes(img image.Image, quality int) ([]byte, error)
- func ImageToPNGBytes(img image.Image) ([]byte, error)
- func SaveImageToJPEG(img image.Image, filename string, quality int) error
- func SaveImageToPNG(img image.Image, filename string) error
- type AnimationBuilder
- func (ab *AnimationBuilder) CreateColorfulParticles(config AnimationConfig) *AnimationBuilder
- func (ab *AnimationBuilder) CreatePulsingCircles(config AnimationConfig) *AnimationBuilder
- func (ab *AnimationBuilder) CreateRotatingShapes(config AnimationConfig) *AnimationBuilder
- func (ab *AnimationBuilder) CreateWaveAnimation(config AnimationConfig) *AnimationBuilder
- func (ab *AnimationBuilder) GetDuration() float64
- func (ab *AnimationBuilder) GetFrameCount() int
- func (ab *AnimationBuilder) SaveToGIF(filename string) error
- func (ab *AnimationBuilder) SetFrameCount(count int) *AnimationBuilder
- func (ab *AnimationBuilder) SetFrameRate(fps int) *AnimationBuilder
- type AnimationConfig
- type ChartElement
- type CircleElement
- type EasingFunc
- type EllipseElement
- type GridElement
- type GroupElement
- type LineElement
- type PathElement
- type PatternElement
- type RectElement
- func (r *RectElement) End() *SVG
- func (r *RectElement) Fill(c color.Color) *RectElement
- func (r *RectElement) Rx(rx float64) *RectElement
- func (r *RectElement) Ry(ry float64) *RectElement
- func (r *RectElement) Stroke(c color.Color) *RectElement
- func (r *RectElement) StrokeWidth(width float64) *RectElement
- type SVG
- func (s *SVG) Background(bgColor color.Color) *SVG
- func (s *SVG) BarChart(data []float64, x, y, width, height float64) *ChartElement
- func (s *SVG) Circle(cx, cy, r float64) *CircleElement
- func (s *SVG) DotPattern(spacing, radius float64) *PatternElement
- func (s *SVG) Ellipse(cx, cy, rx, ry float64) *EllipseElement
- func (s *SVG) GetDocument() *Document
- func (s *SVG) GetImageData(width, height int) (*image.RGBA, error)
- func (s *SVG) GetJPEGData(width, height int, quality int) ([]byte, error)
- func (s *SVG) GetPNGData(width, height int) ([]byte, error)
- func (s *SVG) GetSize() (int, int)
- func (s *SVG) Grid(rows, cols int, cellWidth, cellHeight float64) *GridElement
- func (s *SVG) Group() *GroupElement
- func (s *SVG) Heart(cx, cy, size float64) *ShapeElement
- func (s *SVG) Line(x1, y1, x2, y2 float64) *LineElement
- func (s *SVG) LineChart(data []float64, x, y, width, height float64) *ChartElement
- func (s *SVG) Path(d string) *PathElement
- func (s *SVG) PieChart(data []float64, cx, cy, radius float64) *ChartElement
- func (s *SVG) Polygon(cx, cy, radius float64, sides int) *ShapeElement
- func (s *SVG) Rect(x, y, width, height float64) *RectElement
- func (s *SVG) Render(width, height int) (*image.RGBA, error)
- func (s *SVG) RenderToSize(width, height int) (*image.RGBA, error)
- func (s *SVG) Save(filename string) error
- func (s *SVG) SaveImage(filename string, width, height int, format string, quality ...int) error
- func (s *SVG) SaveJPEG(filename string, width, height int, quality int) error
- func (s *SVG) SavePNG(filename string, width, height int) error
- func (s *SVG) SetSize(width, height int) *SVG
- func (s *SVG) Star(cx, cy, outerRadius float64, points int) *ShapeElement
- func (s *SVG) String() string
- func (s *SVG) Text(x, y float64, text string) *TextElement
- type ShapeElement
- type TextElement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ImageToJPEGBytes ¶
ImageToJPEGBytes 将图像转换为JPEG字节数据 / Convert image to JPEG bytes
func ImageToPNGBytes ¶
ImageToPNGBytes 将图像转换为PNG字节数据 / Convert image to PNG bytes
func SaveImageToJPEG ¶
SaveImageToJPEG 保存图像为JPEG文件 / Save image as JPEG file
Types ¶
type AnimationBuilder ¶
type AnimationBuilder struct {
// contains filtered or unexported fields
}
AnimationBuilder 动画构建器 / Animation Builder
func NewAnimationBuilder ¶
func NewAnimationBuilder(width, height int) *AnimationBuilder
NewAnimationBuilder 创建新的动画构建器 / Create new animation builder
func (*AnimationBuilder) CreateColorfulParticles ¶
func (ab *AnimationBuilder) CreateColorfulParticles(config AnimationConfig) *AnimationBuilder
CreateColorfulParticles 创建彩色粒子动画 / Create colorful particles animation
func (*AnimationBuilder) CreatePulsingCircles ¶
func (ab *AnimationBuilder) CreatePulsingCircles(config AnimationConfig) *AnimationBuilder
CreatePulsingCircles 创建脉冲圆形动画 / Create pulsing circles animation
func (*AnimationBuilder) CreateRotatingShapes ¶
func (ab *AnimationBuilder) CreateRotatingShapes(config AnimationConfig) *AnimationBuilder
CreateRotatingShapes 创建旋转图形动画 / Create rotating shapes animation
func (*AnimationBuilder) CreateWaveAnimation ¶
func (ab *AnimationBuilder) CreateWaveAnimation(config AnimationConfig) *AnimationBuilder
CreateWaveAnimation 创建波浪动画 / Create wave animation
func (*AnimationBuilder) GetDuration ¶
func (ab *AnimationBuilder) GetDuration() float64
GetDuration 获取动画时长(秒) / Get animation duration (seconds)
func (*AnimationBuilder) GetFrameCount ¶
func (ab *AnimationBuilder) GetFrameCount() int
GetFrameCount 获取帧数 / Get frame count
func (*AnimationBuilder) SaveToGIF ¶
func (ab *AnimationBuilder) SaveToGIF(filename string) error
SaveToGIF 保存为GIF文件 / Save to GIF file
func (*AnimationBuilder) SetFrameCount ¶
func (ab *AnimationBuilder) SetFrameCount(count int) *AnimationBuilder
SetFrameCount 设置帧数 / Set frame count
func (*AnimationBuilder) SetFrameRate ¶
func (ab *AnimationBuilder) SetFrameRate(fps int) *AnimationBuilder
SetFrameRate 设置帧率 / Set frame rate
type AnimationConfig ¶
type AnimationConfig struct {
Duration float64 // 动画持续时间(秒) / Animation duration (seconds)
Easing EasingFunc // 缓动函数 / Easing function
Background color.RGBA // 背景颜色 / Background color
Loop bool // 是否循环 / Whether to loop
}
AnimationConfig 动画配置 / Animation configuration
type ChartElement ¶
type ChartElement struct {
// contains filtered or unexported fields
}
ChartElement 图表元素 / Chart element
func (*ChartElement) End ¶
func (c *ChartElement) End() *SVG
func (*ChartElement) Fill ¶
func (c *ChartElement) Fill(color color.Color) *ChartElement
func (*ChartElement) Stroke ¶
func (c *ChartElement) Stroke(color color.Color) *ChartElement
type CircleElement ¶
type CircleElement struct {
// contains filtered or unexported fields
}
CircleElement 圆形元素 / Circle element
func (*CircleElement) End ¶
func (c *CircleElement) End() *SVG
func (*CircleElement) Fill ¶
func (c *CircleElement) Fill(color color.Color) *CircleElement
func (*CircleElement) Stroke ¶
func (c *CircleElement) Stroke(color color.Color) *CircleElement
func (*CircleElement) StrokeWidth ¶
func (c *CircleElement) StrokeWidth(width float64) *CircleElement
type EasingFunc ¶
EasingFunc 缓动函数类型 / Easing function type
var ( // Linear 线性缓动 / Linear easing Linear EasingFunc = func(t float64) float64 { return t } // EaseInOut 缓入缓出 / Ease in-out EaseInOut EasingFunc = func(t float64) float64 { if t < 0.5 { return 2 * t * t } return -1 + (4-2*t)*t } // EaseInQuad 二次方缓入 / Quadratic ease in EaseInQuad EasingFunc = func(t float64) float64 { return t * t } // EaseOutQuad 二次方缓出 / Quadratic ease out EaseOutQuad EasingFunc = func(t float64) float64 { return t * (2 - t) } // EaseInOutQuad 二次方缓入缓出 / Quadratic ease in-out EaseInOutQuad EasingFunc = func(t float64) float64 { if t < 0.5 { return 2 * t * t } return -1 + (4-2*t)*t } // EaseInCubic 三次方缓入 / Cubic ease in EaseInCubic EasingFunc = func(t float64) float64 { return t * t * t } // EaseOutCubic 三次方缓出 / Cubic ease out EaseOutCubic EasingFunc = func(t float64) float64 { t-- return t*t*t + 1 } // Bounce 弹跳效果 / Bounce effect Bounce EasingFunc = func(t float64) float64 { if t < 1/2.75 { return 7.5625 * t * t } else if t < 2/2.75 { t -= 1.5 / 2.75 return 7.5625*t*t + 0.75 } else if t < 2.5/2.75 { t -= 2.25 / 2.75 return 7.5625*t*t + 0.9375 } else { t -= 2.625 / 2.75 return 7.5625*t*t + 0.984375 } } )
预定义缓动函数 / Predefined easing functions
type EllipseElement ¶
type EllipseElement struct {
// contains filtered or unexported fields
}
EllipseElement 椭圆元素 / Ellipse element
func (*EllipseElement) End ¶
func (e *EllipseElement) End() *SVG
func (*EllipseElement) Fill ¶
func (e *EllipseElement) Fill(color color.Color) *EllipseElement
func (*EllipseElement) Stroke ¶
func (e *EllipseElement) Stroke(color color.Color) *EllipseElement
func (*EllipseElement) StrokeWidth ¶
func (e *EllipseElement) StrokeWidth(width float64) *EllipseElement
type GridElement ¶
type GridElement struct {
// contains filtered or unexported fields
}
GridElement 网格元素 / Grid element
func (*GridElement) End ¶
func (g *GridElement) End() *SVG
func (*GridElement) LineColor ¶
func (g *GridElement) LineColor(color color.Color) *GridElement
func (*GridElement) LineWidth ¶
func (g *GridElement) LineWidth(width float64) *GridElement
type GroupElement ¶
type GroupElement struct {
// contains filtered or unexported fields
}
GroupElement 组元素 / Group element
func (*GroupElement) End ¶
func (g *GroupElement) End() *SVG
func (*GroupElement) Rotate ¶
func (g *GroupElement) Rotate(angle float64) *GroupElement
func (*GroupElement) Scale ¶
func (g *GroupElement) Scale(sx, sy float64) *GroupElement
func (*GroupElement) Transform ¶
func (g *GroupElement) Transform(transform string) *GroupElement
func (*GroupElement) Translate ¶
func (g *GroupElement) Translate(x, y float64) *GroupElement
type LineElement ¶
type LineElement struct {
// contains filtered or unexported fields
}
LineElement 直线元素 / Line element
func (*LineElement) End ¶
func (l *LineElement) End() *SVG
func (*LineElement) Stroke ¶
func (l *LineElement) Stroke(color color.Color) *LineElement
func (*LineElement) StrokeWidth ¶
func (l *LineElement) StrokeWidth(width float64) *LineElement
type PathElement ¶
type PathElement struct {
// contains filtered or unexported fields
}
PathElement 路径元素 / Path element
func (*PathElement) End ¶
func (p *PathElement) End() *SVG
func (*PathElement) Fill ¶
func (p *PathElement) Fill(color color.Color) *PathElement
func (*PathElement) Stroke ¶
func (p *PathElement) Stroke(color color.Color) *PathElement
func (*PathElement) StrokeWidth ¶
func (p *PathElement) StrokeWidth(width float64) *PathElement
type PatternElement ¶
type PatternElement struct {
// contains filtered or unexported fields
}
PatternElement 图案元素 / Pattern element
func (*PatternElement) Color ¶
func (p *PatternElement) Color(color color.Color) *PatternElement
func (*PatternElement) End ¶
func (p *PatternElement) End() *SVG
func (*PatternElement) Spacing ¶
func (p *PatternElement) Spacing(spacing float64) *PatternElement
type RectElement ¶
type RectElement struct {
// contains filtered or unexported fields
}
RectElement 矩形元素 / Rectangle element
func (*RectElement) End ¶
func (r *RectElement) End() *SVG
func (*RectElement) Fill ¶
func (r *RectElement) Fill(c color.Color) *RectElement
func (*RectElement) Rx ¶
func (r *RectElement) Rx(rx float64) *RectElement
func (*RectElement) Ry ¶
func (r *RectElement) Ry(ry float64) *RectElement
func (*RectElement) Stroke ¶
func (r *RectElement) Stroke(c color.Color) *RectElement
func (*RectElement) StrokeWidth ¶
func (r *RectElement) StrokeWidth(width float64) *RectElement
type SVG ¶
type SVG struct {
// contains filtered or unexported fields
}
SVG 统一的SVG操作接口 / Unified SVG operation interface
func NewWithViewBox ¶
NewWithViewBox 创建带视图框的SVG实例 / Create SVG instance with viewBox
func (*SVG) Background ¶
Background 设置背景颜色 / Set background color
func (*SVG) BarChart ¶
func (s *SVG) BarChart(data []float64, x, y, width, height float64) *ChartElement
BarChart 创建柱状图 / Create bar chart
func (*SVG) Circle ¶
func (s *SVG) Circle(cx, cy, r float64) *CircleElement
Circle 创建圆形 / Create circle
func (*SVG) DotPattern ¶
func (s *SVG) DotPattern(spacing, radius float64) *PatternElement
DotPattern 创建点图案 / Create dot pattern
func (*SVG) Ellipse ¶
func (s *SVG) Ellipse(cx, cy, rx, ry float64) *EllipseElement
Ellipse 创建椭圆 / Create ellipse
func (*SVG) GetImageData ¶
GetImageData 获取图像数据 / Get image data
func (*SVG) GetJPEGData ¶
GetJPEGData 获取JPEG格式的图像数据 / Get JPEG format image data
func (*SVG) GetPNGData ¶
GetPNGData 获取PNG格式的图像数据 / Get PNG format image data
func (*SVG) Grid ¶
func (s *SVG) Grid(rows, cols int, cellWidth, cellHeight float64) *GridElement
Grid 创建网格 / Create grid
func (*SVG) Heart ¶
func (s *SVG) Heart(cx, cy, size float64) *ShapeElement
Heart 创建心形 / Create heart
func (*SVG) LineChart ¶
func (s *SVG) LineChart(data []float64, x, y, width, height float64) *ChartElement
LineChart 创建折线图 / Create line chart
func (*SVG) PieChart ¶
func (s *SVG) PieChart(data []float64, cx, cy, radius float64) *ChartElement
PieChart 创建饼图 / Create pie chart
func (*SVG) Polygon ¶
func (s *SVG) Polygon(cx, cy, radius float64, sides int) *ShapeElement
Polygon 创建多边形 / Create polygon
func (*SVG) Rect ¶
func (s *SVG) Rect(x, y, width, height float64) *RectElement
Rect 创建矩形 / Create rectangle
func (*SVG) RenderToSize ¶
RenderToSize 渲染到指定尺寸 / Render to specified size
type ShapeElement ¶
type ShapeElement struct {
// contains filtered or unexported fields
}
ShapeElement 形状元素 / Shape element
func (*ShapeElement) End ¶
func (s *ShapeElement) End() *SVG
func (*ShapeElement) Fill ¶
func (s *ShapeElement) Fill(color color.Color) *ShapeElement
func (*ShapeElement) Stroke ¶
func (s *ShapeElement) Stroke(color color.Color) *ShapeElement
func (*ShapeElement) StrokeWidth ¶
func (s *ShapeElement) StrokeWidth(width float64) *ShapeElement
type TextElement ¶
type TextElement struct {
// contains filtered or unexported fields
}
TextElement 文本元素 / Text element
func (*TextElement) End ¶
func (t *TextElement) End() *SVG
func (*TextElement) Fill ¶
func (t *TextElement) Fill(color color.Color) *TextElement
func (*TextElement) FontFamily ¶
func (t *TextElement) FontFamily(family string) *TextElement
func (*TextElement) FontSize ¶
func (t *TextElement) FontSize(size float64) *TextElement
func (*TextElement) FontWeight ¶
func (t *TextElement) FontWeight(weight string) *TextElement
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api provides high-level APIs for SVG creation and manipulation api包为SVG创建和操作提供高级API
|
Package api provides high-level APIs for SVG creation and manipulation api包为SVG创建和操作提供高级API |
|
cmd
|
|
|
example
command
|
|
|
高级动画构建器演示程序 / Advanced Animation Builder Demo
|
高级动画构建器演示程序 / Advanced Animation Builder Demo |
|
example
command
|
|