renderer

package
v0.0.0-...-fb2a099 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateImage

func CreateImage(width, height int, background color.Color) *image.RGBA

CreateImage 创建指定大小和背景色的图像

func DrawAntiAliasedCircle

func DrawAntiAliasedCircle(img *image.RGBA, centerX, centerY, radius float64, color color.RGBA, strokeWidth float64)

DrawAntiAliasedCircle 绘制抗锯齿圆形(描边模式)

func DrawAntiAliasedCircleOutline

func DrawAntiAliasedCircleOutline(img *image.RGBA, centerX, centerY, radius int, c color.Color)

DrawAntiAliasedCircleOutline 绘制抗锯齿圆形轮廓 / Draw anti-aliased circle outline

func DrawAntiAliasedEllipse

func DrawAntiAliasedEllipse(img *image.RGBA, centerX, centerY, radiusX, radiusY float64, color color.RGBA, strokeWidth float64)

DrawAntiAliasedEllipse 绘制抗锯齿椭圆(描边模式)

func DrawAntiAliasedEllipseOutline

func DrawAntiAliasedEllipseOutline(img *image.RGBA, centerX, centerY, radiusX, radiusY int, c color.Color)

DrawAntiAliasedEllipseOutline 绘制抗锯齿椭圆轮廓 / Draw anti-aliased ellipse outline

func DrawAntiAliasedFilledCircle

func DrawAntiAliasedFilledCircle(img *image.RGBA, centerX, centerY, radius int, c color.Color)

DrawAntiAliasedFilledCircle 绘制抗锯齿填充圆形 / Draw anti-aliased filled circle

func DrawAntiAliasedFilledEllipse

func DrawAntiAliasedFilledEllipse(img *image.RGBA, centerX, centerY, radiusX, radiusY int, c color.Color)

DrawAntiAliasedFilledEllipse 绘制抗锯齿填充椭圆 / Draw anti-aliased filled ellipse

func DrawAntiAliasedLine

func DrawAntiAliasedLine(img *image.RGBA, x0, y0, x1, y1 float64, c color.Color, strokeWidth float64)

DrawAntiAliasedLine 绘制抗锯齿直线

func DrawAntiAliasedPixel

func DrawAntiAliasedPixel(img *image.RGBA, x, y float64, c color.Color, alpha float64)

DrawAntiAliasedPixel 绘制抗锯齿像素

func DrawCircle

func DrawCircle(img *image.RGBA, centerX, centerY, radius int, c color.Color, fill bool)

DrawCircle 在图像上绘制圆形(支持填充和描边)/ Draw circle with fill or stroke support

func DrawEllipse

func DrawEllipse(img *image.RGBA, centerX, centerY, radiusX, radiusY int, c color.Color, fill bool)

DrawEllipse 在图像上绘制椭圆(支持填充和描边)/ Draw ellipse with fill or stroke support

func DrawLine

func DrawLine(img *image.RGBA, x0, y0, x1, y1 int, c color.Color)

DrawLine 在图像上绘制直线(使用Bresenham算法)

func DrawPixel

func DrawPixel(img *image.RGBA, x, y int, c color.Color)

DrawPixel 在图像上绘制像素

func DrawRect

func DrawRect(img *image.RGBA, x, y, width, height int, c color.Color, fill bool)

DrawRect 在图像上绘制矩形

func FillCircle

func FillCircle(img *image.RGBA, centerX, centerY, radius int, c color.Color)

FillCircle 在图像上绘制填充圆形

func NewImage

func NewImage(width, height int) *image.RGBA

NewImage 创建新的图像(为了兼容测试)

func RenderDocument

func RenderDocument(doc *types.Document, width, height int) (*image.RGBA, error)

RenderDocument 渲染整个文档(为了兼容测试)

func RenderElement

func RenderElement(img *image.RGBA, element types.Element) error

RenderElement 渲染单个元素(为了兼容测试)

Types

type AntiAliasedPathRenderer

type AntiAliasedPathRenderer struct {
	*AntiAliasedRenderer
}

AntiAliasedPathRenderer 抗锯齿路径渲染器 / Anti-aliased path renderer

func NewAntiAliasedPathRenderer

func NewAntiAliasedPathRenderer() *AntiAliasedPathRenderer

NewAntiAliasedPathRenderer 创建抗锯齿路径渲染器 / Create anti-aliased path renderer

func (*AntiAliasedPathRenderer) RenderPath

func (r *AntiAliasedPathRenderer) RenderPath(img *image.RGBA, pathData string, fillColor, strokeColor color.RGBA, strokeWidth float64, viewBox []float64, scaleX, scaleY float64) error

RenderPath 渲染抗锯齿路径 / Render anti-aliased path

type AntiAliasedRenderer

type AntiAliasedRenderer struct {
	*ImageRenderer
}

AntiAliasedRenderer 抗锯齿渲染器 / Anti-aliased renderer

func NewAntiAliasedRenderer

func NewAntiAliasedRenderer() *AntiAliasedRenderer

NewAntiAliasedRenderer 创建抗锯齿渲染器 / Create anti-aliased renderer

func (*AntiAliasedRenderer) DrawAntiAliasedCircle

func (r *AntiAliasedRenderer) DrawAntiAliasedCircle(img *image.RGBA, centerX, centerY float64, radius float64, c color.RGBA)

DrawAntiAliasedCircle 绘制抗锯齿圆形描边 / Draw anti-aliased circle stroke

func (*AntiAliasedRenderer) DrawAntiAliasedCircleWithWidth

func (r *AntiAliasedRenderer) DrawAntiAliasedCircleWithWidth(img *image.RGBA, centerX, centerY, radius float64, color color.RGBA, strokeWidth float64)

DrawAntiAliasedCircleWithWidth 绘制带描边宽度的抗锯齿圆形

func (*AntiAliasedRenderer) DrawAntiAliasedEllipse

func (r *AntiAliasedRenderer) DrawAntiAliasedEllipse(img *image.RGBA, centerX, centerY, radiusX, radiusY float64, c color.RGBA)

DrawAntiAliasedEllipse 绘制抗锯齿椭圆描边 / Draw anti-aliased ellipse stroke

func (*AntiAliasedRenderer) DrawAntiAliasedEllipseWithWidth

func (r *AntiAliasedRenderer) DrawAntiAliasedEllipseWithWidth(img *image.RGBA, centerX, centerY, radiusX, radiusY float64, color color.RGBA, strokeWidth float64)

DrawAntiAliasedEllipseWithWidth 绘制带描边宽度的抗锯齿椭圆

func (*AntiAliasedRenderer) FillAntiAliasedCircle

func (r *AntiAliasedRenderer) FillAntiAliasedCircle(img *image.RGBA, centerX, centerY float64, radius float64, c color.RGBA)

FillAntiAliasedCircle 填充抗锯齿圆形 / Fill anti-aliased circle

func (*AntiAliasedRenderer) FillAntiAliasedEllipse

func (r *AntiAliasedRenderer) FillAntiAliasedEllipse(img *image.RGBA, centerX, centerY, radiusX, radiusY float64, c color.RGBA)

FillAntiAliasedEllipse 填充抗锯齿椭圆 / Fill anti-aliased ellipse

type EdgeInfo

type EdgeInfo struct {
	X1, Y1, X2, Y2 float64 // 边的起点和终点 / Edge start and end points
	Direction      int     // 边的方向:1表示向上,-1表示向下 / Edge direction: 1 for up, -1 for down
}

EdgeInfo 存储边的信息用于缠绕规则计算 / Edge information for winding rule calculation

type GIFRenderer

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

GIFRenderer GIF动画渲染器

func NewGIFRenderer

func NewGIFRenderer() *GIFRenderer

NewGIFRenderer 创建新的GIF渲染器

func (*GIFRenderer) RenderAnimationFrames

func (g *GIFRenderer) RenderAnimationFrames(frames []*types.Document, width, height int, delay int) (*gif.GIF, error)

RenderAnimationFrames 渲染动画帧序列为GIF

func (*GIFRenderer) RenderAnimationToGIF

func (g *GIFRenderer) RenderAnimationToGIF(frames []*types.Document, width, height int, delay int, filename string) error

RenderAnimationToGIF 直接渲染动画序列为GIF文件

func (*GIFRenderer) SaveGIF

func (g *GIFRenderer) SaveGIF(gifAnim *gif.GIF, filename string) error

SaveGIF 保存GIF动画到文件

type ImageRenderer

type ImageRenderer struct {
}

ImageRenderer 表示SVG到图像的渲染器

func NewImageRenderer

func NewImageRenderer() *ImageRenderer

NewImageRenderer 创建新的图像渲染器

func (*ImageRenderer) FillPath

func (r *ImageRenderer) FillPath(img *image.RGBA, points []types.Point, fillColor color.RGBA)

FillPath 公开的填充路径方法 / Public fill path method

func (*ImageRenderer) FillSubPathsWithWindingRule

func (r *ImageRenderer) FillSubPathsWithWindingRule(img *image.RGBA, subPaths [][]types.Point, fillColor color.RGBA)

FillSubPathsWithWindingRule 公开的填充多个子路径方法 / Public fill multiple sub-paths method

func (*ImageRenderer) Render

func (r *ImageRenderer) Render(doc *types.Document, width, height int) (*image.RGBA, error)

Render 将SVG文档渲染为图像

type IntersectionInfo

type IntersectionInfo struct {
	X         float64 // 交点的x坐标 / X coordinate of intersection
	Direction int     // 边的方向 / Edge direction
}

IntersectionInfo 交点信息 / Intersection information

type PathBounds

type PathBounds struct {
	MinX, MinY, MaxX, MaxY float64
}

PathBounds 路径边界框结构 / Path bounds structure

type StrokeCapStyle

type StrokeCapStyle int

StrokeCapStyle 线帽样式 / Stroke cap style

const (
	CapButt   StrokeCapStyle = iota // 平头线帽 / Butt cap
	CapRound                        // 圆形线帽 / Round cap
	CapSquare                       // 方形线帽 / Square cap
)

type StrokeJoinStyle

type StrokeJoinStyle int

StrokeJoinStyle 线段连接样式 / Stroke join style

const (
	JoinMiter StrokeJoinStyle = iota // 尖角连接 / Miter join
	JoinRound                        // 圆角连接 / Round join
	JoinBevel                        // 斜角连接 / Bevel join
)

type TrueStrokePathGenerator

type TrueStrokePathGenerator struct {
	CapStyle   StrokeCapStyle  // 线帽样式 / Cap style
	JoinStyle  StrokeJoinStyle // 连接样式 / Join style
	MiterLimit float64         // 尖角限制 / Miter limit
}

TrueStrokePathGenerator 真正的描边路径生成器 / True stroke path generator

func NewTrueStrokePathGenerator

func NewTrueStrokePathGenerator() *TrueStrokePathGenerator

NewTrueStrokePathGenerator 创建新的描边路径生成器 / Create new stroke path generator

func (*TrueStrokePathGenerator) GenerateStrokePath

func (g *TrueStrokePathGenerator) GenerateStrokePath(path []types.Point, strokeWidth float64, closePath bool) []types.Point

GenerateStrokePath 生成真正的描边路径 / Generate true stroke path

type TrueStrokeRenderer

type TrueStrokeRenderer struct {
	*AntiAliasedPathRenderer
	PathGenerator *TrueStrokePathGenerator
}

TrueStrokeRenderer 真正的描边渲染器 / True stroke renderer

func NewTrueStrokeRenderer

func NewTrueStrokeRenderer() *TrueStrokeRenderer

NewTrueStrokeRenderer 创建新的真正描边渲染器 / Create new true stroke renderer

func (*TrueStrokeRenderer) RenderTrueStroke

func (r *TrueStrokeRenderer) RenderTrueStroke(img *image.RGBA, path []types.Point, strokeColor color.RGBA, strokeWidth float64, closePath bool)

RenderTrueStroke 渲染真正的描边 / Render true stroke

func (*TrueStrokeRenderer) RenderTrueStrokeComplexPath

func (r *TrueStrokeRenderer) RenderTrueStrokeComplexPath(img *image.RGBA, subPaths [][]types.Point, strokeColor color.RGBA, strokeWidth float64, closeSubPaths []bool)

RenderTrueStrokeComplexPath 渲染复杂路径的真正描边 / Render true stroke for complex path

type WebLevelStrokeRenderer

type WebLevelStrokeRenderer struct {
	*AntiAliasedPathRenderer
}

WebLevelStrokeRenderer Web级别描边抗锯齿渲染器

func NewWebLevelStrokeRenderer

func NewWebLevelStrokeRenderer() *WebLevelStrokeRenderer

NewWebLevelStrokeRenderer 创建Web级别描边抗锯齿渲染器

func (*WebLevelStrokeRenderer) StrokeComplexPathWebLevel

func (r *WebLevelStrokeRenderer) StrokeComplexPathWebLevel(img *image.RGBA, subPaths [][]types.Point, strokeColor color.RGBA, strokeWidth float64, closeSubPaths []bool)

StrokeComplexPathWebLevel 使用Web级别抗锯齿渲染复杂路径描边

func (*WebLevelStrokeRenderer) StrokeWebLevelAntiAliased

func (r *WebLevelStrokeRenderer) StrokeWebLevelAntiAliased(img *image.RGBA, path []types.Point, strokeColor color.RGBA, strokeWidth float64, closePath bool)

StrokeWebLevelAntiAliased 使用Web级别超高效抗锯齿算法进行描边

Jump to

Keyboard shortcuts

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