scene/tag.go
Functions
func DataSize
func (t Tag) DataSize() int {
switch t {
case TagTransform:
return 6
case TagMoveTo, TagLineTo:
return 2
case TagQuadTo:
return 4
case TagCubicTo:
return 6
case TagFillRoundRect:
return 6 // minX, minY, maxX, maxY, radiusX, radiusY
case TagBrush:
return 4 // RGBA
default:
return 0
}
}
func IsClipCommand
IsClipCommand returns true if the tag is a clip command.
func (t Tag) IsClipCommand() bool {
return t == TagBeginClip || t == TagEndClip
}
func IsDrawCommand
IsDrawCommand returns true if the tag is a draw command (fill/stroke/text).
func (t Tag) IsDrawCommand() bool {
return t == TagFill || t == TagFillRoundRect || t == TagStroke || t == TagText
}
func IsLayerCommand
IsLayerCommand returns true if the tag is a layer command.
func (t Tag) IsLayerCommand() bool {
return t == TagPushLayer || t == TagPopLayer
}
func IsPathCommand
IsPathCommand returns true if the tag is a path construction command.
func (t Tag) IsPathCommand() bool {
return t >= TagBeginPath && t <= TagEndPath
}
func String
String returns a human-readable name for the tag.
nolint:cyclop // simple switch dispatch over all tag values
func (t Tag) String() string {
switch t {
case TagTransform:
return "Transform"
case TagSetAntiAlias:
return "SetAntiAlias"
case TagBeginPath:
return "BeginPath"
case TagMoveTo:
return "MoveTo"
case TagLineTo:
return "LineTo"
case TagQuadTo:
return "QuadTo"
case TagCubicTo:
return "CubicTo"
case TagClosePath:
return "ClosePath"
case TagEndPath:
return "EndPath"
case TagFill:
return "Fill"
case TagFillRoundRect:
return "FillRoundRect"
case TagStroke:
return "Stroke"
case TagPushLayer:
return "PushLayer"
case TagPopLayer:
return "PopLayer"
case TagBeginClip:
return "BeginClip"
case TagEndClip:
return "EndClip"
case TagBrush:
return "Brush"
case TagImage:
return "Image"
case TagText:
return "Text"
default:
return unknownStr
}
}
DataSize returns the number of float32 values this tag consumes from pathData.
Returns -1 for tags that don't use pathData.