Documentation
¶
Overview ¶
Package testscene 提供后端一致性测试共用的“页面场景”与配套图元/度量: 同一段 DrawContext 绘制命令可依次作用到不同光栅后端,用于逐像素对照 与速度测试。它只依赖 geom 数学结构与一个与 render.DrawContext 结构 等价的本地接口(Renderer),因此不引入 render 包,避免内部测试包与插件 包之间的 import cycle。
Index ¶
- func AppendCircleGeom(p *geom.Path, cx, cy, r float64) *geom.Path
- func CirclePathGeom(cx, cy, r float64) *geom.Path
- func LoadTestFace(t testing.TB, fontPath string) *canvas.FontFace
- func MaskedChecker() image.Image
- func OffscreenGradient() image.Image
- func PickTestFont() string
- func RoundedRectPath(x0, y0, x1, y1, r float64) *geom.Path
- func SceneBackend(t testing.TB, b Renderer, fontPath string)
- func SceneDirect(t testing.TB, ctx *canvas.Context, fontPath string)
- func WavePath() *geom.Path
- type DiffStat
- type Renderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendCircleGeom ¶
AppendCircleGeom 在路径后追加一个圆。
func LoadTestFace ¶
LoadTestFace 从字体文件加载测试字体 14px。
func OffscreenGradient ¶
OffscreenGradient 返回离屏预渲染的线性渐变图,用作按完整矩阵贴回的素材。
func RoundedRectPath ¶
RoundedRectPath 返回圆角矩形路径。
func SceneBackend ¶
SceneBackend 用 Renderer(即 render.DrawContext 的实现)绘制与 SceneDirect 完全一致、仅方法调度方式不同的测试场景。
func SceneDirect ¶
SceneDirect 用 canvas.Context 的既有调用风格绘制测试场景(含背景、图片、 开放路径描边、EvenOdd 双圆、渐变矩形、布尔裁剪、字形文字、虚线圆角矩形、 离屏图贴回与描边复制)。
Types ¶
type DiffStat ¶
type DiffStat struct {
Changed int // 至少一个通道差异的像素数
Hot int // 任一个通道差异 > 32 的像素数
MaxDelta int // 最大单通道差异(0..255)
AvgDelta float64 // 平均单通道差异(全部字节)
}
DiffStat 统计两图逐通道(RRGGBBAA,premultiplied)差异。
type Renderer ¶
type Renderer interface {
SetFillColor(c color.Color)
SetFillGradient(g geom.Gradient)
SetFillRule(rule geom.FillRule)
ClearFill()
SetStrokeColor(c color.Color)
SetStrokeWidth(w float64)
SetStrokeCapper(cap geom.Capper)
SetStrokeJoiner(join geom.Joiner)
ClearStroke()
SetDashes(offset float64, dashes ...float64)
DrawPath(x, y float64, p *geom.Path)
DrawImage(img image.Image, x, y float64, dpmm float64)
TextPath(p *geom.Path, x, y float64)
RenderImage(img image.Image, m geom.Matrix)
CopyStrokeToFill()
CurrentMatrix() geom.Matrix
}
Renderer 是本包场景所需的绘制操作面,方法签名与 render.DrawContext 中 对应方法完全一致。canvas 后端与各栅格插件后端(gogpu/gg、FloatTech/gg、 tinyskia)都满足该接口。