lottie

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: BSD-3-Clause, MIT Imports: 40 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lottie renders Lottie animations with okage. It is a port of the crate velato, with the changes of D42, D43, D79, D82, D85 and D94 (D41).

Parse reads a Lottie file into a Composition. RenderFrame draws a frame of it onto an okage pixmap:

c, err := lottie.Parse(data)
if err != nil {
	return err
}
pm, _ := okage.NewPixmap(uint32(c.Width), uint32(c.Height))
m := pm.AsMut()
if err := lottie.RenderFrame(c, c.Frames[0], lottie.IdentityAffine, &m); err != nil {
	return err
}

A program that shows Lottie files can use the helpers of D44. Detect finds a Lottie document from the start of a file, OpenDotLottie reads a dotLottie archive, Load parses either one, and Composition.Image draws a frame into an *image.RGBA of a given size:

c, err := lottie.Load(data)
if err != nil {
	return err
}
img, err := c.Image(c.FrameCount()/2, 512, 512)

A Renderer draws onto any Sink, the interface of velato for a renderer. PixmapSink is the Sink that draws with okage. It draws the image assets that a file embeds as data URLs, and the image files of the fs.FS of WithFS. RenderFrame and Composition.Image read the image files of a dotLottie archive from the archive (D75).

The package also draws the text layers, which velato does not parse. A text layer draws the glyphs of the list chars of its file. A PixmapSink shapes each other character with the fonts of WithFontDatabase. A text layer also draws its text animators, the capitals of its text and its text on a path, as ThorVG does (D85). The PixmapSink also draws the Gaussian blur and the drop shadow of a layer, as ThorVG does (D79), at the quality of WithQuality (D94):

sink := lottie.NewPixmapSink(&m, lottie.WithFontDatabase(db))
err := lottie.NewRenderer().Append(c, frame, lottie.IdentityAffine, 1, sink)

The package draws as ThorVG does where velato differs, as D43 lists. It ignores expressions, as velato does, and draws the values of the keyframes (D91). The test module compares it with velato and with ThorVG on the Noto animated emoji.

Index

Constants

View Source
const (
	PathElMoveTo    = kurbo.PathElMoveTo
	PathElLineTo    = kurbo.PathElLineTo
	PathElQuadTo    = kurbo.PathElQuadTo
	PathElCurveTo   = kurbo.PathElCurveTo
	PathElClosePath = kurbo.PathElClosePath
)

The variants of PathEl.

Variables

View Source
var (
	ColorTransparent = Color{0, 0, 0, 0}
	ColorBlack       = Color{0, 0, 0, 1}
	ColorWhite       = Color{1, 1, 1, 1}
)

The colors that velato names.

View Source
var IdentityAffine = kurbo.IdentityAffine

IdentityAffine is Affine::IDENTITY.

Functions

func Detect added in v0.7.0

func Detect(head []byte) bool

Detect reports whether head is the start of a Lottie document. head can be cut short at any byte. Detect reads only the top level of the object, and returns true when each of the keys fr, ip, op, w and h holds a number there. No one of these keys is rare, but a JSON document that has all five at its top level, each with a number, is a Lottie document.

A writer such as bodymovin puts these keys before the assets and the layers. In the 879 Noto animated emoji, the last of them ends at byte 52 or before. So a few kilobytes of the start of a file are enough.

func IsDotLottie added in v0.7.0

func IsDotLottie(head []byte) bool

IsDotLottie reports whether head is the start of a zip archive, and so of a dotLottie archive and not of a bare Lottie document. It does not read the archive.

func RenderFrame

func RenderFrame(c *Composition, frame float64, transform kurbo.Affine, pixmap *okage.PixmapMut) error

RenderFrame renders the frame of c onto pixmap under transform, with a new Renderer and a PixmapSink. The sink reads the image files of a composition that DotLottie.Parse or Load returns from its archive, and keeps the decoded images in c for the next frames (D75).

Types

type Affine

type Affine = kurbo.Affine

Affine is kurbo::Affine.

func AffineScale

func AffineScale(s float64) Affine

AffineScale is Affine::scale.

func AffineScaleNonUniform added in v0.7.0

func AffineScaleNonUniform(sx, sy float64) Affine

AffineScaleNonUniform is Affine::scale_non_uniform.

type Animated

type Animated[T any] struct {
	Times  []Time
	Values []T
	// contains filtered or unexported fields
}

Animated is Animated in velato src/runtime/model/value.rs: the keyframes of a value and the function that tweens between two values.

func (*Animated[T]) EvaluateOr

func (a *Animated[T]) EvaluateOr(frame float64, def T) T

EvaluateOr is Animated::evaluate_or in velato src/runtime/model/value.rs.

type AnimatedBrush

type AnimatedBrush struct {
	IsGradient bool
	Solid      Value[Color]
	Gradient   AnimatedGradient
}

AnimatedBrush is Brush in velato src/runtime/model/animated.rs: a solid color, or a gradient (D27).

func (*AnimatedBrush) Evaluate

func (b *AnimatedBrush) Evaluate(alpha, frame float64) Brush

Evaluate is Brush::evaluate in velato src/runtime/model/animated.rs.

func (*AnimatedBrush) IsFixed

func (b *AnimatedBrush) IsFixed() bool

IsFixed is Brush::is_fixed in velato src/runtime/model/animated.rs.

type AnimatedColorStops

type AnimatedColorStops struct {
	Frames []Time
	Values [][]float64
	Count  int
	// contains filtered or unexported fields
}

AnimatedColorStops is ColorStops in velato src/runtime/model/animated.rs. Each value is the raw gradient data of a keyframe, with Count color stops.

Port: velato keeps five numbers for each color stop, with the alpha that conv_stops gives, and tweens them. okage keeps the raw data, tweens it, and then makes the stops with gradientStops (D43).

func (*AnimatedColorStops) Evaluate

func (c *AnimatedColorStops) Evaluate(frame float64) ColorStops

Evaluate is ColorStops::evaluate in velato src/runtime/model/animated.rs.

type AnimatedEllipse

type AnimatedEllipse struct {
	// True if the ellipse is drawn in CCW order.
	IsCCW bool
	// Position of the ellipse.
	Position Position
	// Size of the ellipse.
	Size Value[kurbo.Size]
}

AnimatedEllipse is Ellipse in velato src/runtime/model/animated.rs.

func (*AnimatedEllipse) Evaluate

func (e *AnimatedEllipse) Evaluate(frame float64, path []kurbo.PathEl) []kurbo.PathEl

Evaluate is Ellipse::evaluate in velato src/runtime/model/animated.rs, without the feature lottie-shape-paths.

type AnimatedGradient

type AnimatedGradient struct {
	// True if the gradient is radial.
	IsRadial bool
	// Starting point.
	StartPoint Value[kurbo.Point]
	// Ending point.
	EndPoint Value[kurbo.Point]
	// Stop offsets and color values.
	Stops ColorStopsValue
	// Port: the highlight length, in percent of the radius, and the
	// highlight angle in degrees, of a radial gradient (D43).
	HighlightLength Value[float64]
	HighlightAngle  Value[float64]
}

AnimatedGradient is Gradient in velato src/runtime/model/animated.rs.

func (*AnimatedGradient) Evaluate

func (g *AnimatedGradient) Evaluate(frame float64) Brush

Evaluate is Gradient::evaluate in velato src/runtime/model/animated.rs.

func (*AnimatedGradient) IsFixed

func (g *AnimatedGradient) IsFixed() bool

IsFixed is Gradient::is_fixed in velato src/runtime/model/animated.rs.

type AnimatedProperty

type AnimatedProperty[T any] struct {
	PropertyIndex *float64 `json:"ix,omitempty"`
	Animated      *BoolInt `json:"a,omitempty"`
	Expression    *string  `json:"x,omitempty"`
	SlotID        *string  `json:"sid,omitempty"`
	Value         AnimatedPropertyK[T]
}

AnimatedProperty is AnimatedProperty in velato src/schema/animated_properties/animated_property.rs: a property that is a static value of type T, or a list of keyframes.

func (*AnimatedProperty[T]) UnmarshalJSON

func (p *AnimatedProperty[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the property. The key "k" is required.

type AnimatedPropertyK

type AnimatedPropertyK[T any] struct {
	Keyframes []Keyframe
	Static    T
	// IsAnimated is true for the variant AnimatedValue.
	IsAnimated bool
}

AnimatedPropertyK is AnimatedPropertyK in velato src/schema/animated_properties/animated_property.rs. It is an untagged enum: a list of keyframes, or a static value (D27). Keyframes is nil for a static value.

func (*AnimatedPropertyK[T]) UnmarshalJSON

func (k *AnimatedPropertyK[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON tries the keyframes first, then the static value, as serde tries the variants of an untagged enum in order.

type AnimatedRect

type AnimatedRect struct {
	// True if the rect is drawn in CCW order.
	IsCCW bool
	// Position of the rectangle.
	Position Position
	// Size of the rectangle.
	Size Value[kurbo.Size]
	// Radius of the rectangle corners.
	CornerRadius Value[float64]
}

AnimatedRect is Rect in velato src/runtime/model/animated.rs.

func (*AnimatedRect) Evaluate

func (r *AnimatedRect) Evaluate(frame float64, path []kurbo.PathEl) []kurbo.PathEl

Evaluate is Rect::evaluate in velato src/runtime/model/animated.rs, without the feature lottie-shape-paths.

type AnimatedRepeater

type AnimatedRepeater struct {
	// Number of times elements are repeated.
	Copies Value[float64]
	// Offset applied to each element.
	Offset Value[float64]
	// Anchor point.
	AnchorPoint Position
	// Translation.
	Position Position
	// Rotation in degrees.
	Rotation Value[float64]
	// Scale.
	Scale Value[kurbo.Vec2]
	// Opacity of the first element.
	StartOpacity Value[float64]
	// Opacity of the last element.
	EndOpacity Value[float64]
	// How copies are stacked relative to the original shape.
	Composite RepeaterComposite
}

AnimatedRepeater is Repeater in velato src/runtime/model/animated.rs.

func (*AnimatedRepeater) Evaluate

func (r *AnimatedRepeater) Evaluate(frame float64) FixedRepeater

Evaluate is Repeater::evaluate in velato src/runtime/model/animated.rs.

func (*AnimatedRepeater) IsFixed

func (r *AnimatedRepeater) IsFixed() bool

IsFixed is Repeater::is_fixed in velato src/runtime/model/animated.rs.

type AnimatedSpline

type AnimatedSpline struct {
	// True if the spline is closed.
	IsClosed bool
	// Collection of times.
	Times []Time
	// Collection of splines for each time.
	Values []SplineKeyframeValues
}

AnimatedSpline is Spline in velato src/runtime/model/animated.rs: an animated cubic spline.

func (*AnimatedSpline) Evaluate

func (s *AnimatedSpline) Evaluate(frame float64, path []kurbo.PathEl) ([]kurbo.PathEl, bool)

Evaluate is Spline::evaluate in velato src/runtime/model/animated.rs. It appends the spline at frame to path.

type AnimatedStar

type AnimatedStar struct {
	IsPolygon      bool
	Direction      float64
	Position       Position
	InnerRadius    Value[float64]
	InnerRoundness Value[float64]
	OuterRadius    Value[float64]
	OuterRoundness Value[float64]
	Rotation       Value[float64]
	Points         Value[float64]
}

AnimatedStar is Star in velato src/runtime/model/animated.rs: a star or a polygon.

func (*AnimatedStar) Evaluate

func (s *AnimatedStar) Evaluate(frame float64, path []kurbo.PathEl) []kurbo.PathEl

Evaluate is Star::evaluate in velato src/runtime/model/animated.rs. It appends the star or polygon at frame to path.

func (*AnimatedStar) IsFixed

func (s *AnimatedStar) IsFixed() bool

IsFixed is Star::is_fixed in velato src/runtime/model/animated.rs.

type AnimatedStroke

type AnimatedStroke struct {
	// Width of the stroke.
	Width Value[float64]
	// Join style.
	Join Join
	// Limit for miter joins, or nil.
	MiterLimit *float64
	// Cap style.
	Cap Cap
	// Port: the lengths of the dashes and the gaps, in their order, and the
	// offset of the pattern (D43).
	Dashes     []Value[float64]
	DashOffset Value[float64]
}

AnimatedStroke is Stroke in velato src/runtime/model/animated.rs.

func (*AnimatedStroke) Evaluate

func (s *AnimatedStroke) Evaluate(frame float64) Stroke

Evaluate is Stroke::evaluate in velato src/runtime/model/animated.rs.

type AnimatedTransform

type AnimatedTransform struct {
	// Anchor point.
	Anchor Position
	// Translation.
	Position Position
	// Rotation angle.
	Rotation Value[float64]
	// Scale factor.
	Scale Value[kurbo.Vec2]
	// Skew factor.
	Skew Value[float64]
	// Skew angle, 0 skews along the x axis, 90 along the y axis.
	SkewAngle Value[float64]
}

AnimatedTransform is Transform in velato src/runtime/model/animated.rs.

func (*AnimatedTransform) Components

func (t *AnimatedTransform) Components(frame float64) TransformComponents

Components is Transform::components in velato src/runtime/model/animated.rs.

func (*AnimatedTransform) Evaluate

func (t *AnimatedTransform) Evaluate(frame float64) kurbo.Affine

Evaluate is Transform::evaluate in velato src/runtime/model/animated.rs.

func (*AnimatedTransform) IsFixed

func (t *AnimatedTransform) IsFixed() bool

IsFixed is Transform::is_fixed in velato src/runtime/model/animated.rs.

type AnimatedTrim

type AnimatedTrim struct {
	Mode TrimMode
	// Start of the visible segment (0.0 to 100.0).
	Start Value[float64]
	// End of the visible segment (0.0 to 100.0).
	End Value[float64]
	// Offset rotation in degrees.
	Offset Value[float64]
}

AnimatedTrim is Trim in velato src/runtime/model/animated.rs.

func (*AnimatedTrim) Evaluate

func (t *AnimatedTrim) Evaluate(frame float64) FixedTrim

Evaluate is Trim::evaluate in velato src/runtime/model/animated.rs.

type Animation

type Animation struct {
	VisualObject
	CompositionSchema

	Version          *string         `json:"v,omitempty"`
	Ver              *uint32         `json:"ver,omitempty"`
	FrameRate        float64         `json:"fr"`
	InPoint          float64         `json:"ip"`
	OutPoint         float64         `json:"op"`
	Width            uint            `json:"w"`
	Height           uint            `json:"h"`
	ThreeDimensional *BoolInt        `json:"ddd,omitempty"`
	Assets           []AnyAsset      `json:"assets,omitempty"`
	Markers          []Marker        `json:"markers,omitempty"`
	Meta             *Meta           `json:"meta,omitempty"`
	Metadata         json.RawMessage `json:"metadata,omitempty"`

	// Port: velato does not read the fonts and the glyphs of the text
	// layers (D79).
	Fonts *FontList  `json:"fonts,omitempty"`
	Chars []CharData `json:"chars,omitempty"`
}

Animation is Animation in velato src/schema/animation/animation.rs: the top level object of a Lottie file.

func ParseAnimation

func ParseAnimation(data []byte) (*Animation, error)

ParseAnimation is Animation::from_slice in velato src/schema/animation/animation.rs.

Port: serde reads only the types of the schema. ParseAnimation also reads a file that does not follow the schema exactly, such as a width of 200.0 or a boolean of 1, as decode says (D110).

type AnyAsset

type AnyAsset struct {
	Image          *Image
	Precomposition *Precomposition
}

AnyAsset is AnyAsset in velato src/schema/assets/mod.rs: an image or a precomposition (D27).

func (*AnyAsset) UnmarshalJSON

func (a *AnyAsset) UnmarshalJSON(data []byte) error

UnmarshalJSON picks the type of the asset by its keys, as velato does.

type AnyLayer

type AnyLayer struct {
	Precomposition *PrecompositionLayer
	Solid          *SolidLayer
	Shape          *ShapeLayer
	Null           *NullLayer
	Image          *ImageLayer
	// Text is a text layer.
	//
	// Port: velato does not parse a text layer, and gives an error for it.
	// okage parses it (D79).
	Text *TextLayer
}

AnyLayer is AnyLayer in velato src/schema/layers/mod.rs: a layer of the type that "ty" names (D27).

func (*AnyLayer) UnmarshalJSON

func (l *AnyLayer) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the layer of the type that "ty" names.

Port: velato gives an error for a layer of another type, such as a camera or an audio layer, and for a layer with no type. okage reads such a layer as a null layer, so that its children keep their parent, as in ThorVG. Its keys are not required, and its position is 0, 0 when it has none (D110).

type AnyShape

type AnyShape struct {
	Type           string
	Group          *GroupShape
	Rectangle      *RectangleShape
	Ellipse        *EllipseShape
	Transform      *TransformShape
	Stroke         *StrokeShape
	PuckerBloat    *PuckerBloatShape
	Merge          *MergeShape
	Repeater       *RepeaterShape
	OffsetPath     *OffsetPathShape
	Fill           *FillShape
	Trim           *TrimPathShape
	Path           *PathShape
	GradientFill   *GradientFillShape
	GradientStroke *GradientStrokeShape
	Twist          *TwistShape
	RoundedCorners *RoundedCornersShape
	PolyStar       *PolyStarShape
}

AnyShape is AnyShape in velato src/schema/shapes/mod.rs: a shape item, tagged by its key "ty" (D27). The field of the type holds the item.

func (*AnyShape) UnmarshalJSON

func (s *AnyShape) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the item of the type that "ty" names.

Port: velato gives an error for an item of another type, and for an item with no type. okage keeps the type and no item, and the conversion skips it, as ThorVG does (D110).

type AnyTransformP

type AnyTransformP struct {
	Position      PositionSchema
	SplitPosition SplitVector
	IsSplit       bool
}

AnyTransformP is AnyTransformP in velato src/schema/helpers/transform.rs: a position, or a split position (D27).

func (*AnyTransformP) UnmarshalJSON

func (p *AnyTransformP) UnmarshalJSON(data []byte) error

UnmarshalJSON tries a position first, then a split position.

type AnyTransformR

type AnyTransformR struct {
	Rotation    FloatValue
	XRotation   FloatValue
	YRotation   FloatValue
	ZRotation   FloatValue
	Orientation MultiDimensional
	IsSplit     bool
}

AnyTransformR is AnyTransformR in velato src/schema/helpers/transform.rs: a rotation, or a split rotation (D27).

func (*AnyTransformR) UnmarshalJSON

func (r *AnyTransformR) UnmarshalJSON(data []byte) error

UnmarshalJSON tries a rotation first, then a split rotation.

type Asset

type Asset struct {
	VisualObject

	ID string `json:"id"`
}

Asset is Asset in velato src/schema/assets/asset.rs.

type BaseGradientShape

type BaseGradientShape struct {
	Colors          GradientColors   `json:"g"`
	StartPoint      MultiDimensional `json:"s"`
	EndPoint        MultiDimensional `json:"e"`
	GradientType    *GradientType    `json:"t,omitempty"`
	HighlightLength *FloatValue      `json:"h,omitempty"`
	HighlightAngle  *FloatValue      `json:"a,omitempty"`
}

BaseGradientShape is BaseGradientShape in velato src/schema/shapes/base_gradient.rs.

type BaseStrokeShape

type BaseStrokeShape struct {
	LineCap        *LineCap          `json:"lc,omitempty"`
	LineJoin       *LineJoin         `json:"lj,omitempty"`
	MiterLimit     *float64          `json:"ml,omitempty"`
	MiterLimitAnim *FloatValue       `json:"ml2,omitempty"`
	Width          FloatValue        `json:"w"`
	Dashes         []StrokeDashShape `json:"d,omitempty"`
}

BaseStrokeShape is BaseStrokeShape in velato src/schema/shapes/base_stroke.rs.

type Bezier

type Bezier struct {
	Closed      *bool        `json:"c,omitempty"`
	Vertices    [][2]float64 `json:"v"`
	InTangents  [][2]float64 `json:"i"`
	OutTangents [][2]float64 `json:"o"`
}

Bezier is Bezier in velato src/schema/helpers/bezier.rs.

func (*Bezier) UnmarshalJSON

func (b *Bezier) UnmarshalJSON(data []byte) error

UnmarshalJSON requires the keys "v", "i" and "o".

type BlendMode

type BlendMode struct {
	Mix     Mix
	Compose Compose
}

BlendMode is peniko::BlendMode: a mix and a compose mode.

type BlendModeSchema

type BlendModeSchema uint8

BlendModeSchema is BlendMode in velato src/schema/constants/blend_mode.rs.

const (
	BlendModeNormal BlendModeSchema = iota
	BlendModeMultiply
	BlendModeScreen
	BlendModeOverlay
	BlendModeDarken
	BlendModeLighten
	BlendModeColorDodge
	BlendModeColorBurn
	BlendModeHardLight
	BlendModeSoftLight
	BlendModeDifference
	BlendModeExclusion
	BlendModeHue
	BlendModeSaturation
	BlendModeColor
	BlendModeLuminosity
	BlendModeAdd
	BlendModeHardMix
)

The values of BlendMode.

func (*BlendModeSchema) UnmarshalJSON

func (m *BlendModeSchema) UnmarshalJSON(data []byte) error

UnmarshalJSON reads a value from 0 to 17.

type BlurEdgeMode

type BlurEdgeMode uint8

BlurEdgeMode is BlurEdgeMode in velato src/runtime/effects.rs: how Gaussian blur samples outside the source bounds.

const (
	// BlurDuplicate extends the edge samples beyond the source bounds.
	BlurDuplicate BlurEdgeMode = iota
	// BlurWrap tiles the source outside its bounds.
	BlurWrap
)

The values of BlurEdgeMode.

type BoolInt

type BoolInt uint8

BoolInt is BoolInt in velato src/schema/helpers/int_boolean.rs: 0 is false and 1 is true.

const (
	BoolIntFalse BoolInt = 0
	BoolIntTrue  BoolInt = 1
)

The values of BoolInt.

func (*BoolInt) UnmarshalJSON

func (b *BoolInt) UnmarshalJSON(data []byte) error

UnmarshalJSON reads 0 or 1.

Port: velato takes only 0 and 1. okage takes any number, a boolean, or a string that holds a number, and a value that is not 0 is true, as in ThorVG (D110).

type Brush

type Brush struct {
	Kind     BrushKind
	Color    Color
	Gradient Gradient
}

Brush is peniko::Brush, with the kinds solid and gradient.

func (Brush) MultiplyAlpha

func (b Brush) MultiplyAlpha(alpha float32) Brush

MultiplyAlpha is Brush::multiply_alpha in peniko.

type BrushKind

type BrushKind uint8

BrushKind is the kind of a peniko::Brush.

const (
	BrushSolid BrushKind = iota
	BrushGradient
)

The kinds of a brush.

type BrushValue

type BrushValue struct {
	Fixed    Brush
	Animated *AnimatedBrush
}

BrushValue is Brush in velato src/runtime/model/mod.rs: a fixed or an animated brush (D27).

func (BrushValue) Evaluate

func (b BrushValue) Evaluate(alpha, frame float64) Brush

Evaluate is Brush::evaluate in velato src/runtime/model/mod.rs.

type Cap

type Cap uint8

Cap is kurbo::Cap.

const (
	CapButt Cap = iota
	CapSquare
	CapRound
)

The caps of a stroke.

type CharData added in v0.19.0

type CharData struct {
	// Char is the text that the glyph draws, often one character.
	Char string `json:"ch"`
	// Size is the font size of the outline, often 100.
	Size float64 `json:"size"`
	// Family and Style name the font of the glyph, with the keys fFamily
	// and fStyle of the font list.
	Family string `json:"fFamily"`
	Style  string `json:"style"`
	// Width is the advance of the glyph, at the font size 100.
	Width float64 `json:"w"`
	// Data holds the shapes of the outline.
	Data CharShapes `json:"data"`
}

CharData is a glyph of the list chars of a file.

type CharShapes added in v0.19.0

type CharShapes struct {
	Shapes []AnyShape `json:"shapes"`
}

CharShapes holds the outline of a glyph as a list of shapes, groups of paths, at the font size 100.

type Color

type Color [4]float32

Color is peniko::Color, an AlphaColor of sRGB: the components red, green, blue and alpha, from 0 to 1, with straight alpha.

func (Color) MultiplyAlpha

func (c Color) MultiplyAlpha(alpha float32) Color

MultiplyAlpha is AlphaColor::multiply_alpha in the crate color.

func (Color) WithAlpha

func (c Color) WithAlpha(alpha float32) Color

WithAlpha is AlphaColor::with_alpha in the crate color.

type ColorStop

type ColorStop struct {
	Offset float32
	Color  Color
}

ColorStop is peniko::ColorStop: a color at an offset of a gradient.

type ColorStops

type ColorStops []ColorStop

ColorStops is peniko::ColorStops.

type ColorStopsValue

type ColorStopsValue struct {
	Fixed    ColorStops
	Animated *AnimatedColorStops
}

ColorStopsValue is ColorStops in velato src/runtime/model/mod.rs: fixed or animated color stops (D27).

func (ColorStopsValue) Evaluate

func (c ColorStopsValue) Evaluate(frame float64) ColorStops

Evaluate is ColorStops::evaluate in velato src/runtime/model/mod.rs.

func (ColorStopsValue) IsFixed

func (c ColorStopsValue) IsFixed() bool

IsFixed is ColorStops::is_fixed in velato src/runtime/model/mod.rs.

type ColorValue

type ColorValue struct {
	AnimatedProperty[[]float64]
}

ColorValue is ColorValue in velato src/schema/animated_properties/color_value.rs.

type Compose

type Compose uint8

Compose is peniko::Compose, the Porter-Duff modes.

const (
	ComposeClear Compose = iota
	ComposeCopy
	ComposeDest
	ComposeSrcOver
	ComposeDestOver
	ComposeSrcIn
	ComposeDestIn
	ComposeSrcOut
	ComposeDestOut
	ComposeSrcAtop
	ComposeDestAtop
	ComposeXor
	ComposePlus
	ComposePlusLighter
)

The values of Compose, in the order of peniko.

type Composite

type Composite uint8

Composite is Composite in velato src/schema/constants/composite.rs.

const (
	CompositeBelow Composite = 1
	CompositeAbove Composite = 2
)

The values of Composite.

func (*Composite) UnmarshalJSON

func (c *Composite) UnmarshalJSON(data []byte) error

UnmarshalJSON reads 1 or 2.

type Composition

type Composition struct {
	// Frames in which the animation is active: [Frames[0], Frames[1]).
	Frames [2]float64
	// Frames per second.
	FrameRate float64
	// Width of the animation.
	Width uint
	// Height of the animation.
	Height uint
	// Precomposed layers that can be instanced, by the id of the asset.
	Assets map[string][]Layer
	// Raster image assets, keyed by the identifier of a layer's refId.
	Images map[string]ImageAsset
	// Collection of layers.
	Layers []Layer
	// Fonts holds the fonts of the text layers, by their name, with their
	// glyphs.
	//
	// Port: velato has no text layer (D79).
	Fonts map[string]*Font
	// contains filtered or unexported fields
}

Composition is Composition in velato src/runtime/mod.rs: the model of a Lottie file.

func Load added in v0.7.0

func Load(data []byte) (*Composition, error)

Load returns the composition of data, which is a Lottie document or a dotLottie archive. For an archive, it returns the composition of the first of its Animations.

func Parse

func Parse(data []byte) (*Composition, error)

Parse is Composition::from_slice in velato src/runtime/mod.rs: the composition of the Lottie file in data.

func (*Composition) Duration added in v0.7.0

func (c *Composition) Duration() time.Duration

Duration returns the time that all the frames of c show.

func (*Composition) Evaluate

func (c *Composition) Evaluate(frame float64) (*EvaluatedComposition, error)

Evaluate is Composition::evaluate in velato src/runtime/evaluate.rs: the layers at a frame, without drawing.

func (*Composition) FrameCount added in v0.7.0

func (c *Composition) FrameCount() int

FrameCount returns the number of frames of c, from Frames[0] up to and not including Frames[1]. It returns 0 for a composition with no frames.

func (*Composition) FrameDuration added in v0.7.0

func (c *Composition) FrameDuration() time.Duration

FrameDuration returns the time that one frame of c shows, from the frame rate. It returns 0 for a frame rate that is not finite and positive.

func (*Composition) Image added in v0.7.0

func (c *Composition) Image(n, w, h int) (*image.RGBA, error)

Image draws frame n of c, counted from Frames[0], into a new image of w by h pixels. It scales the width of the composition by w/Width and its height by h/Height, so the composition fills the image. The image is premultiplied, as an image.RGBA is. Image returns an error that wraps okage.ErrLottieEmpty when c has no size or no frames, when n is not one of its frames, or when w or h is not positive.

type CompositionSchema

type CompositionSchema struct {
	Layers []AnyLayer `json:"layers"`
}

CompositionSchema is Composition in velato src/schema/animation/composition.rs.

type Content

type Content struct {
	Kind ContentKind
	// Name is the asset of an instance, or the image of an image layer.
	Name string
	// TimeRemap is the time remap of an instance, or nil.
	TimeRemap *Value[float64]
	// Shapes is the collection of shapes of a shape layer.
	Shapes []Shape
	// Color is the color of a solid layer, and Width and Height its size.
	Color         Color
	Width, Height float64
	// Text holds the text documents of a text layer (D79).
	Text []TextKeyframe
	// TextAnimation holds the text animators and the path of a text
	// layer, or nil (D85).
	TextAnimation *TextAnimation
}

Content is Content in velato src/runtime/model/mod.rs (D27).

type ContentKind

type ContentKind uint8

ContentKind is the variant of Content in velato src/runtime/model/mod.rs.

const (
	ContentNone ContentKind = iota
	ContentInstance
	ContentImage
	ContentShape
	// ContentSolid is a solid layer.
	//
	// Port: velato gives a solid layer no content. okage fills its
	// rectangle with its color, as ThorVG does (D43).
	ContentSolid
	// ContentText is a text layer.
	//
	// Port: velato does not parse a text layer. okage draws its glyphs
	// (D79).
	ContentText
)

The variants of Content.

type DotLottie added in v0.7.0

type DotLottie struct {
	// Animations holds the paths of the Lottie documents in the archive, in
	// sorted order.
	Animations []string
	// contains filtered or unexported fields
}

DotLottie is a dotLottie archive: a zip archive that holds one or more Lottie documents.

func OpenDotLottie added in v0.7.0

func OpenDotLottie(r io.ReaderAt, size int64) (*DotLottie, error)

OpenDotLottie reads the directory of the dotLottie archive in r, which has size bytes.

The dotLottie format puts its documents in the folder animations/ and describes them in manifest.json. OpenDotLottie takes each .json file of animations/. If that folder has no .json file, it takes each other .json file of the archive except manifest.json. It returns an error that wraps okage.ErrLottieDotLottie when r is not a zip archive or when it has no document.

func (*DotLottie) Data added in v0.7.0

func (d *DotLottie) Data(name string) ([]byte, error)

Data returns the bytes of the file name of the archive, such as one of Animations.

func (*DotLottie) FS added in v0.7.0

func (d *DotLottie) FS() fs.FS

FS returns the files of the archive.

func (*DotLottie) Parse added in v0.7.0

func (d *DotLottie) Parse(name string) (*Composition, error)

Parse returns the composition of the document name of the archive, such as one of Animations. RenderFrame and Composition.Image read the image files of the composition from the archive (D75).

type Draw

type Draw struct {
	// Parameters for a stroked draw operation, or nil for a fill.
	Stroke *StrokeValue
	// Brush for the draw operation.
	Brush BrushValue
	// Opacity of the draw operation.
	Opacity Value[float64]
}

Draw is Draw in velato src/runtime/model/mod.rs: a fill or a stroke.

type Easing

type Easing struct {
	O EasingHandle
	I EasingHandle
}

Easing is Easing in velato src/runtime/model/value.rs.

type EasingHandle

type EasingHandle struct {
	X, Y float64
}

EasingHandle is EasingHandle in velato src/runtime/model/value.rs.

type EllipseShape

type EllipseShape struct {
	ShapeSchema

	Position PositionSchema   `json:"p"`
	Size     MultiDimensional `json:"s"`
}

EllipseShape is EllipseShape in velato src/schema/shapes/ellipse.rs.

type EvaluatedComposition

type EvaluatedComposition struct {
	Layers []EvaluatedLayer
	// contains filtered or unexported fields
}

EvaluatedComposition is EvaluatedComposition in velato src/runtime/evaluate.rs.

func (*EvaluatedComposition) Get

Get is EvaluatedComposition::get in velato src/runtime/evaluate.rs.

type EvaluatedLayer

type EvaluatedLayer struct {
	Path  OccurrencePath
	Layer *Layer
	// Transform-parent index in the containing composition, or -1.
	Parent int
	// Matte mode and source index in the containing composition, or nil.
	Matte *evaluatedMatte
	// Frame in the containing composition.
	Frame float64
	// Frame is at or after the layer's in-point and before its out-point.
	InRange bool
	// Active in the normal render tree.
	Visible bool
	// The authored components, and false for a matrix-only transform.
	AuthoredComponents   TransformComponents
	HasAuthoredComponent bool
	// Layer-to-parent transform, or layer-to-composition if parentless.
	LocalTransform kurbo.Affine
	// Places layer coordinates in the main composition.
	FullTransform kurbo.Affine
	// Layer's own opacity, from 0 to 1.
	Opacity float64
	// Layers inside this precomposition instance.
	Children []EvaluatedLayer
}

EvaluatedLayer is EvaluatedLayer in velato src/runtime/evaluate.rs: one layer instance at a frame. Coordinates are pixels, with y down.

func (*EvaluatedLayer) EvaluatedPaths

func (l *EvaluatedLayer) EvaluatedPaths() [][]kurbo.PathEl

EvaluatedPaths is EvaluatedLayer::evaluated_paths in velato src/runtime/evaluate.rs: the paths of a shape layer after its transforms, trims and repeaters, in pixels of the main animation.

type EvaluationError

type EvaluationError struct {
	Kind EvaluationErrorKind
	// Path of the layer, for the kinds about a layer.
	Path OccurrencePath
	// ID is the authored ind of an unresolved parent or matte.
	ID int
	// Name is the asset of MissingAsset and PrecompCycle.
	Name string
}

EvaluationError is EvaluationError in velato src/runtime/evaluate.rs. It wraps okage.ErrLottieEvaluation.

func (*EvaluationError) Error

func (e *EvaluationError) Error() string

Error is impl Display for EvaluationError in velato src/runtime/evaluate.rs.

func (*EvaluationError) Unwrap

func (e *EvaluationError) Unwrap() error

Unwrap returns okage.ErrLottieEvaluation.

type EvaluationErrorKind

type EvaluationErrorKind uint8

EvaluationErrorKind is the variant of EvaluationError in velato src/runtime/evaluate.rs.

const (
	EvalNonFiniteTime EvaluationErrorKind = iota
	EvalInvalidStretch
	EvalInvalidTransform
	EvalInvalidParent
	EvalUnresolvedParent
	EvalParentCycle
	EvalInvalidMatte
	EvalUnresolvedMatte
	EvalMatteCycle
	EvalMissingAsset
	EvalPrecompCycle
)

The variants of EvaluationError.

type FileAsset

type FileAsset struct {
	Asset

	Dir      *string  `json:"u,omitempty"`
	FileName string   `json:"p"`
	Embedded *BoolInt `json:"e,omitempty"`
}

FileAsset is FileAsset in velato src/schema/assets/file_asset.rs.

type FillRule

type FillRule uint8

FillRule is FillRule in velato src/schema/constants/fill_rule.rs.

const (
	FillRuleNonZero FillRule = 1
	FillRuleEvenOdd FillRule = 2
)

The values of FillRule.

func (*FillRule) UnmarshalJSON

func (r *FillRule) UnmarshalJSON(data []byte) error

UnmarshalJSON reads 1 or 2.

type FillShape

type FillShape struct {
	ShapeStyleShape

	Color    ColorValue `json:"c"`
	FillRule *FillRule  `json:"r,omitempty"`
}

FillShape is FillShape in velato src/schema/shapes/fill.rs.

type FilterEffect

type FilterEffect struct {
	Kind LayerEffectKind
	// GaussianBlur.
	StdDeviation kurbo.Vec2
	EdgeMode     BlurEdgeMode
	// DropShadow, and Color for Fill.
	Color              Color
	Offset             kurbo.Vec2
	ShadowStdDeviation float64
	// Tint.
	Black, White Color
	Amount       float64
}

FilterEffect is FilterEffect in velato src/runtime/effects.rs: a layer effect evaluated for one frame (D27). Each kind uses the fields of its Rust variant.

type FilterLayerResult

type FilterLayerResult uint8

FilterLayerResult is FilterLayerResult in velato src/runtime/effects.rs.

const (
	FilterPushed FilterLayerResult = iota
	FilterUnsupported
)

The values of FilterLayerResult.

type FixedRepeater

type FixedRepeater struct {
	// Number of times to repeat.
	Copies int
	// Offset of each subsequent repeated element.
	Offset float64
	// Anchor point.
	AnchorPoint kurbo.Point
	// Translation.
	Position kurbo.Point
	// Rotation in degrees.
	Rotation float64
	// Scale.
	Scale kurbo.Vec2
	// Opacity of the first element.
	StartOpacity float64
	// Opacity of the last element.
	EndOpacity float64
	// How copies are stacked relative to the original shape.
	Composite RepeaterComposite
}

FixedRepeater is Repeater in velato src/runtime/model/fixed.rs.

func (*FixedRepeater) Transform

func (r *FixedRepeater) Transform(index int) kurbo.Affine

Transform is Repeater::transform in velato src/runtime/model/fixed.rs: the transform for the copy index.

type FixedTrim

type FixedTrim struct {
	Mode TrimMode
	// Start of the visible segment (0.0 to 100.0).
	Start float64
	// End of the visible segment (0.0 to 100.0).
	End float64
	// Offset rotation in degrees.
	Offset float64
}

FixedTrim is Trim in velato src/runtime/model/fixed.rs.

func (FixedTrim) Normalized

func (t FixedTrim) Normalized() (trimRange, *trimRange, bool)

Normalized is Trim::normalized in velato src/runtime/model/fixed.rs. It returns the first range, the second range when the offset wraps around, and false when the trim shows nothing.

type FloatValue

type FloatValue struct {
	AnimatedProperty[float64]
}

FloatValue is FloatValue in velato src/schema/animated_properties/value.rs.

type Font added in v0.19.0

type Font struct {
	// Name, Family and Style are the keys fName, fFamily and fStyle.
	Name   string
	Family string
	Style  string
	// Ascent is the height above the baseline, in hundredths of the font
	// size.
	Ascent float64
	// Glyphs are the glyphs of the list chars that have the family and the
	// style of the font, in the order of the file.
	Glyphs []Glyph
}

Font is a font of the font list of a file.

type FontList added in v0.19.0

type FontList struct {
	List []FontSchema `json:"list"`
}

FontList is the list of the fonts of a file, its key fonts.

type FontSchema added in v0.19.0

type FontSchema struct {
	// Name is the name that a text document names the font by.
	Name string `json:"fName"`
	// Family and Style are the family and the style of the font, such as
	// "Noto Sans" and "Bold Italic".
	Family string `json:"fFamily"`
	Style  string `json:"fStyle"`
	// Path is the place of the font file, or a data URL.
	Path string `json:"fPath"`
	// Ascent is the height of the font above the baseline, in hundredths of
	// the font size.
	Ascent float64 `json:"ascent"`
	// Origin is 0 when the glyphs of the font are in the list chars.
	Origin int `json:"origin"`
}

FontSchema is a font of the font list.

type Geometry

type Geometry struct {
	Kind    GeometryKind
	Path    []kurbo.PathEl
	Rect    *AnimatedRect
	Ellipse *AnimatedEllipse
	Spline  *AnimatedSpline
	Star    *AnimatedStar
}

Geometry is Geometry in velato src/runtime/model/mod.rs (D27). The field of its kind holds the geometry.

func (*Geometry) Evaluate

func (g *Geometry) Evaluate(frame float64, path []kurbo.PathEl) []kurbo.PathEl

Evaluate is Geometry::evaluate in velato src/runtime/model/mod.rs. It appends the path at frame to path.

type GeometryKind

type GeometryKind uint8

GeometryKind is the variant of Geometry in velato src/runtime/model/mod.rs.

const (
	GeometryFixed GeometryKind = iota
	GeometryRect
	GeometryEllipse
	GeometrySpline
	GeometryStar
)

The variants of Geometry.

type Glyph added in v0.19.0

type Glyph struct {
	// Text is the text that the glyph draws.
	Text string
	// Width is the advance of the glyph at the font size 100.
	Width float64
	// Path is the outline of the glyph at the font size 100, with y down
	// and the baseline at y = 0.
	Path []kurbo.PathEl
}

Glyph is a glyph of the list chars of a file.

type Gradient

type Gradient struct {
	Kind   GradientKind
	Start  kurbo.Point
	End    kurbo.Point
	Radius float32
	Stops  ColorStops
	// Focal is the focal point of a radial gradient, which is Start when
	// the gradient has no highlight.
	//
	// Port: peniko's new_radial has no focal point. okage takes the
	// highlight of a Lottie radial gradient, as ThorVG does (D43).
	Focal kurbo.Point
}

Gradient is peniko::Gradient, with the two kinds that velato makes. A linear gradient goes from Start to End. A radial gradient has its center at Start and its radius in Radius, as Gradient::new_radial makes it. The gradient pads its ends.

type GradientColors

type GradientColors struct {
	Colors MultiDimensional `json:"k"`
	Count  uint             `json:"p"`
}

GradientColors is GradientColors in velato src/schema/animated_properties/gradient_colors.rs.

func (*GradientColors) UnmarshalJSON

func (g *GradientColors) UnmarshalJSON(data []byte) error

UnmarshalJSON requires the keys "k" and "p".

type GradientFillShape

type GradientFillShape struct {
	ShapeStyleShape
	BaseGradientShape

	FillRule *FillRule `json:"r,omitempty"`
}

GradientFillShape is GradientFillShape in velato src/schema/shapes/gradient_fill.rs.

type GradientKind

type GradientKind uint8

GradientKind is the kind of a peniko::Gradient.

const (
	GradientLinear GradientKind = iota
	GradientRadial
)

The kinds of a gradient.

type GradientStrokeShape

type GradientStrokeShape struct {
	ShapeStyleShape
	BaseStrokeShape
	BaseGradientShape
}

GradientStrokeShape is GradientStrokeShape in velato src/schema/shapes/gradient_stroke.rs.

type GradientType

type GradientType uint8

GradientType is GradientType in velato src/schema/constants/gradient_type.rs.

const (
	GradientTypeLinear GradientType = 1
	GradientTypeRadial GradientType = 2
)

The values of GradientType.

func (*GradientType) UnmarshalJSON

func (g *GradientType) UnmarshalJSON(data []byte) error

UnmarshalJSON reads 1 or 2.

type GraphicElementShape

type GraphicElementShape struct {
	VisualObject

	Hidden        *bool            `json:"hd,omitempty"`
	BlendMode     *BlendModeSchema `json:"bm,omitempty"`
	PropertyIndex *float64         `json:"ix,omitempty"`
	CSSClass      *string          `json:"cl,omitempty"`
	XMLID         *string          `json:"ln,omitempty"`
	Index         *float64         `json:"ind,omitempty"`
}

GraphicElementShape is GraphicElementShape in velato src/schema/shapes/graphic_element.rs.

type GroupShape

type GroupShape struct {
	GraphicElementShape

	NumProperties *float64   `json:"np,omitempty"`
	Shapes        []AnyShape `json:"it"`
	PropertyIdx   *uint8     `json:"cix,omitempty"`
}

GroupShape is GroupShape in velato src/schema/shapes/group.rs.

type GroupTransform

type GroupTransform struct {
	Transform Transform
	Opacity   Value[float64]
}

GroupTransform is GroupTransform in velato src/runtime/model/mod.rs.

type Image

type Image struct {
	FileAsset

	SlotID   *string  `json:"sid,omitempty"`
	Width    *float64 `json:"w,omitempty"`
	Height   *float64 `json:"h,omitempty"`
	Sequence *bool    `json:"-"`
}

Image is Image in velato src/schema/assets/image.rs.

type ImageAsset

type ImageAsset struct {
	// Identifier referenced by an image layer's refId.
	ID string
	// Authored display width in pixels, or nil.
	Width *float64
	// Authored display height in pixels, or nil.
	Height *float64
	// Directory or URL prefix from the asset's u field, or nil.
	Directory *string
	// File name or data URL from the asset's p field.
	FileName string
	// Whether the asset is marked as embedded by its e field.
	Embedded bool
}

ImageAsset is ImageAsset in velato src/runtime/model/mod.rs: the metadata of a raster image. A Sink loads and decodes it.

func (*ImageAsset) IsDataURL

func (a *ImageAsset) IsDataURL() bool

IsDataURL is ImageAsset::is_data_url in velato src/runtime/model/mod.rs.

func (*ImageAsset) Location

func (a *ImageAsset) Location() string

Location is ImageAsset::location in velato src/runtime/model/mod.rs: the directory and the file name, or the unchanged data URL.

type ImageLayer

type ImageLayer struct {
	VisualLayer

	RefID string `json:"refId"`
}

ImageLayer is ImageLayer in velato src/schema/layers/image.rs.

type Join

type Join uint8

Join is kurbo::Join.

const (
	JoinBevel Join = iota
	JoinMiter
	JoinRound
)

The joins of a stroke.

type Keyframe

type Keyframe struct {
	Base               KeyframeBase
	Value              []float64
	EndValueDeprecated []float64
}

Keyframe is Keyframe in velato src/schema/animated_properties/keyframe.rs.

func (*Keyframe) UnmarshalJSON

func (k *Keyframe) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the keyframe. The keys "t" and "s" are required.

type KeyframeBase

type KeyframeBase struct {
	Time       float64               `json:"t"`
	Hold       *BoolInt              `json:"h,omitempty"`
	InTangent  *KeyframeBezierHandle `json:"i,omitempty"`
	OutTangent *KeyframeBezierHandle `json:"o,omitempty"`
}

KeyframeBase is KeyframeBase in velato src/schema/animated_properties/keyframe_base.rs.

type KeyframeBezierHandle

type KeyframeBezierHandle struct {
	XCoordinate KeyframeComponent `json:"x"`
	YCoordinate KeyframeComponent `json:"y"`
}

KeyframeBezierHandle is KeyframeBezierHandle in velato src/schema/animated_properties/keyframe_bezier_handle.rs.

func (*KeyframeBezierHandle) UnmarshalJSON

func (h *KeyframeBezierHandle) UnmarshalJSON(data []byte) error

UnmarshalJSON requires the keys "x" and "y".

type KeyframeComponent

type KeyframeComponent struct {
	Values  []float64
	Single  float64
	IsArray bool
}

KeyframeComponent is KeyframeComponent in velato src/schema/animated_properties/keyframe_bezier_handle.rs: an array of values, or a single value (D27).

func (*KeyframeComponent) UnmarshalJSON

func (c *KeyframeComponent) UnmarshalJSON(data []byte) error

UnmarshalJSON reads an array or a number.

type Layer

type Layer struct {
	// Excluded from normal rendering, but still usable as a matte source or
	// parent.
	Hidden  bool
	Effects []LayerEffect
	// Effects that import could not convert.
	UnsupportedEffects []UnsupportedEffect
	// Name of the layer.
	Name string
	// Transform parent in the same composition, or nil.
	Parent *LayerReference
	// Transform for the entire layer.
	Transform Transform
	// Opacity for the entire layer.
	Opacity Value[float64]
	// Width and Height of the layer.
	Width, Height float64
	// Blend mode for the layer, or nil.
	BlendMode *BlendMode
	// Range of frames in which the layer is active: [Frames[0], Frames[1]).
	Frames [2]float64
	// Frame time stretch factor.
	Stretch float64
	// Starting frame for the layer (only applied to instances).
	StartFrame float64
	// List of masks applied to the content.
	Masks []Mask
	// True if the layer is used as a matte source.
	IsMatteSource bool
	// Matte blend mode and source layer, or nil.
	Matte *LayerMatte
	// Content of the layer.
	Content Content
}

Layer is Layer in velato src/runtime/model/mod.rs.

type LayerEffect

type LayerEffect struct {
	Kind LayerEffectKind
	// GaussianBlur.
	Blurriness, Dimensions, Wrap Value[float64]
	// DropShadow, and Color for Fill.
	Color                              Value[Color]
	Opacity, Angle, Distance, Softness Value[float64]
	// Tint.
	Black, White Value[Color]
	Amount       Value[float64]
}

LayerEffect is LayerEffect in velato src/runtime/model/mod.rs: a layer effect with animated parameters (D27). Each kind uses the fields that its Rust variant has.

func (*LayerEffect) Evaluate

func (e *LayerEffect) Evaluate(frame float64) (FilterEffect, bool)

Evaluate is LayerEffect::evaluate in velato src/runtime/effects.rs. It returns false where the effect does nothing at frame.

type LayerEffectKind

type LayerEffectKind uint8

LayerEffectKind is the variant of LayerEffect in velato src/runtime/model/mod.rs.

const (
	// EffectGaussianBlur is the Gaussian Blur effect, ty 29.
	EffectGaussianBlur LayerEffectKind = iota
	// EffectDropShadow is the Drop Shadow effect, ty 25.
	EffectDropShadow
	// EffectFill is the Fill effect, ty 21.
	EffectFill
	// EffectTint is the Tint effect, ty 20.
	EffectTint
)

The variants of LayerEffect.

type LayerMatte

type LayerMatte struct {
	Mode   BlendMode
	Source LayerReference
}

LayerMatte is the matte of a layer: its blend mode and its source.

type LayerReference

type LayerReference struct {
	Index    int
	Resolved bool
}

LayerReference is LayerReference in velato src/runtime/model/mod.rs: a resolved index in the containing composition, or an authored ind that import did not find.

type LayerSchema

type LayerSchema struct {
	VisualObject

	ThreeDimensional *BoolInt `json:"ddd,omitempty"`
	Hidden           *bool    `json:"hd,omitempty"`
	LayerType        uint8    `json:"ty"`
	Index            *uint    `json:"ind,omitempty"`
	ParentIndex      *uint    `json:"parent,omitempty"`
	TimeStretch      *float64 `json:"sr,omitempty"`
	InPoint          float64  `json:"ip"`
	OutPoint         float64  `json:"op"`
	StartTime        *float64 `json:"st,omitempty"`
}

LayerSchema is Layer in velato src/schema/layers/layer.rs.

type LineCap

type LineCap uint8

LineCap is LineCap in velato src/schema/constants/line_cap.rs.

const (
	LineCapButt   LineCap = 1
	LineCapRound  LineCap = 2
	LineCapSquare LineCap = 3
)

The values of LineCap.

func (*LineCap) UnmarshalJSON

func (c *LineCap) UnmarshalJSON(data []byte) error

UnmarshalJSON reads a value from 1 to 3.

type LineJoin

type LineJoin uint8

LineJoin is LineJoin in velato src/schema/constants/line_join.rs.

const (
	LineJoinMiter LineJoin = 1
	LineJoinRound LineJoin = 2
	LineJoinBevel LineJoin = 3
)

The values of LineJoin.

func (*LineJoin) UnmarshalJSON

func (j *LineJoin) UnmarshalJSON(data []byte) error

UnmarshalJSON reads a value from 1 to 3.

type Marker

type Marker struct {
	Comment  *string  `json:"cm,omitempty"`
	Time     *float64 `json:"tm,omitempty"`
	Duration *float64 `json:"dr,omitempty"`
}

Marker is Marker in velato src/schema/helpers/marker.rs.

type Mask

type Mask struct {
	// Blend mode for the mask.
	Mode BlendMode
	// Geometry that defines the shape of the mask.
	Geometry Geometry
	// Opacity of the mask.
	Opacity Value[float64]
	// Port: the mode, the inversion and the expansion of the mask, which
	// velato does not read (D43).
	MaskMode MaskMode
	Inverted bool
	Expand   Value[float64]
}

Mask is Mask in velato src/runtime/model/mod.rs.

type MaskMode

type MaskMode string

MaskMode is MaskMode in velato src/schema/constants/mask_mode.rs.

const (
	MaskModeNone       MaskMode = "n"
	MaskModeAdd        MaskMode = "a"
	MaskModeSubtract   MaskMode = "s"
	MaskModeIntersect  MaskMode = "i"
	MaskModeLighten    MaskMode = "l"
	MaskModeDarken     MaskMode = "d"
	MaskModeDifference MaskMode = "f"
)

The values of MaskMode.

func (*MaskMode) UnmarshalJSON

func (m *MaskMode) UnmarshalJSON(data []byte) error

UnmarshalJSON reads one of the letters of the modes.

type MaskSchema

type MaskSchema struct {
	Name      *string        `json:"nm,omitempty"`
	MatchName *string        `json:"mn,omitempty"`
	Inverted  *bool          `json:"inv,omitempty"`
	Shape     *ShapeProperty `json:"pt,omitempty"`
	Opacity   *FloatValue    `json:"o,omitempty"`
	Mode      *MaskMode      `json:"mode,omitempty"`
	Expand    *FloatValue    `json:"x,omitempty"`
}

MaskSchema is Mask in velato src/schema/helpers/mask.rs.

type MatteMode

type MatteMode uint8

MatteMode is MatteMode in velato src/schema/constants/matte_mode.rs.

const (
	MatteModeNormal MatteMode = iota
	MatteModeAlpha
	MatteModeInvertedAlpha
	MatteModeLuma
	MatteModeInvertedLuma
)

The values of MatteMode.

func (*MatteMode) UnmarshalJSON

func (m *MatteMode) UnmarshalJSON(data []byte) error

UnmarshalJSON reads a value from 0 to 4.

type MergeMode

type MergeMode uint8

MergeMode is MergeMode in velato src/schema/constants/merge_mode.rs.

const (
	MergeModeNormal               MergeMode = 1
	MergeModeAdd                  MergeMode = 2
	MergeModeSubtract             MergeMode = 3
	MergeModeIntersect            MergeMode = 4
	MergeModeExcludeIntersections MergeMode = 5
)

The values of MergeMode.

func (*MergeMode) UnmarshalJSON

func (m *MergeMode) UnmarshalJSON(data []byte) error

UnmarshalJSON reads a value from 1 to 5.

type MergeShape

type MergeShape struct {
	GraphicElementShape

	MergeMode *MergeMode `json:"mm,omitempty"`
}

MergeShape is MergeShape in velato src/schema/shapes/merge.rs.

type Meta

type Meta struct {
	Author      *string         `json:"a,omitempty"`
	Description *string         `json:"d,omitempty"`
	ThemeColor  *string         `json:"tc,omitempty"`
	Generator   *string         `json:"g,omitempty"`
	Keywords    json.RawMessage `json:"k,omitempty"`
}

Meta is Meta in velato src/schema/animation/meta.rs.

type Mix

type Mix uint8

Mix is peniko::Mix, the separable and non-separable blend modes.

const (
	MixNormal Mix = iota
	MixMultiply
	MixScreen
	MixOverlay
	MixDarken
	MixLighten
	MixColorDodge
	MixColorBurn
	MixHardLight
	MixSoftLight
	MixDifference
	MixExclusion
	MixHue
	MixSaturation
	MixColor
	MixLuminosity
)

The values of Mix, in the order of peniko.

type ModifierShape

type ModifierShape struct {
	GraphicElementShape
}

ModifierShape is ModifierShape in velato src/schema/shapes/modifier.rs.

type MultiDimensional

type MultiDimensional struct {
	AnimatedProperty[[]float64]

	Length *float64
}

MultiDimensional is MultiDimensional in velato src/schema/animated_properties/multi_dimensional.rs.

func (*MultiDimensional) UnmarshalJSON

func (m *MultiDimensional) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the property and its key "l".

type NullLayer

type NullLayer struct {
	VisualLayer
}

NullLayer is NullLayer in velato src/schema/layers/null.rs.

type OccurrencePath

type OccurrencePath []int

OccurrencePath is OccurrencePath in velato src/runtime/evaluate.rs: nested layer indices, not Lottie IDs.

type OffsetPathShape

type OffsetPathShape struct {
	ModifierShape

	Amount     *FloatValue `json:"a,omitempty"`
	LineJoin   *LineJoin   `json:"lj,omitempty"`
	MiterLimit *FloatValue `json:"ml,omitempty"`
}

OffsetPathShape is OffsetPathShape in velato src/schema/shapes/offset_path.rs.

type PathEl

type PathEl = kurbo.PathEl

PathEl is kurbo::PathEl.

type PathElKind

type PathElKind = kurbo.PathElKind

PathElKind is the variant of kurbo::PathEl.

type PathShape

type PathShape struct {
	ShapeSchema

	ShapeProperty ShapeProperty `json:"ks"`
}

PathShape is PathShape in velato src/schema/shapes/path.rs.

type PixmapSink

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

PixmapSink is a Sink that draws onto an okage pixmap. Each layer is a pixmap of the size of the target, from a pool. A layer keeps the rectangle that its draws touch, and PopLayer composites only that rectangle onto the layer below, with its blend mode, its opacity and its clip. A clip that is a rectangle on the pixel grid needs no mask.

func NewPixmapSink

func NewPixmapSink(target *okage.PixmapMut, opts ...SinkOption) *PixmapSink

NewPixmapSink returns a sink that draws onto target, with the options opts.

func (*PixmapSink) BeginLayerGroup

func (s *PixmapSink) BeginLayerGroup(string, int)

BeginLayerGroup does nothing.

func (*PixmapSink) Draw

func (s *PixmapSink) Draw(stroke *Stroke, transform kurbo.Affine, brush *Brush, shape []kurbo.PathEl)

Draw fills shape, or strokes it when stroke is not nil, with brush under transform. A fill uses the nonzero rule, as the sinks of velato do.

func (*PixmapSink) DrawImage

func (s *PixmapSink) DrawImage(asset *ImageAsset, transform kurbo.Affine, alpha float64)

DrawImage draws the image of asset under transform, with its opacity scaled by alpha, as ThorVG draws it (D75). The top-left corner of the image is at the origin. The image is scaled to fit in the width and the height of the asset, and it keeps its aspect ratio, as ThorVG does. A side that the asset does not give takes the size of the decoded image. The sink decodes a data URL, or reads the path of the asset from the files of WithFS. It decodes each image once, and keeps it for the next frames. An image that the sink cannot read or decode draws nothing, and the sink logs it to the logger of WithLogger.

func (*PixmapSink) EndLayerGroup

func (s *PixmapSink) EndLayerGroup()

EndLayerGroup does nothing.

func (*PixmapSink) PopLayer

func (s *PixmapSink) PopLayer()

PopLayer ends the last layer, and composites it onto the layer below.

func (*PixmapSink) PushClipLayer

func (s *PixmapSink) PushClipLayer(transform kurbo.Affine, shape []kurbo.PathEl)

PushClipLayer starts a layer clipped to shape under transform.

func (*PixmapSink) PushFilter

func (s *PixmapSink) PushFilter(transform kurbo.Affine, effect *FilterEffect) FilterLayerResult

PushFilter starts a layer for a Fill, a Tint, a Gaussian blur or a drop shadow effect of a layer under transform. The sinks of velato for Vello draw no effect (D41, D43, D79).

func (*PixmapSink) PushLayer

func (s *PixmapSink) PushLayer(blend BlendMode, alpha float32, transform kurbo.Affine, shape []kurbo.PathEl)

PushLayer starts a layer that composites with blend and alpha, clipped to shape under transform.

type Point

type Point = kurbo.Point

Point is kurbo::Point.

type PolyStarShape

type PolyStarShape struct {
	ShapeSchema

	Position       PositionSchema `json:"p"`
	OuterRadius    FloatValue     `json:"or"`
	OuterRoundness FloatValue     `json:"os"`
	Rotation       FloatValue     `json:"r"`
	Points         FloatValue     `json:"pt"`
	StarType       StarType       `json:"sy"`
	InnerRadius    *FloatValue    `json:"ir,omitempty"`
	InnerRoundness *FloatValue    `json:"is,omitempty"`
}

PolyStarShape is PolyStarShape in velato src/schema/shapes/polystar.rs.

type Position

type Position struct {
	Kind    PositionKind
	Value   Value[kurbo.Point]
	X, Y    Value[float64]
	Spatial *SpatialPosition
}

Position is Position in velato src/runtime/model/animated.rs (D27).

func (*Position) Evaluate

func (p *Position) Evaluate(frame float64) kurbo.Point

Evaluate is Position::evaluate in velato src/runtime/model/animated.rs.

func (*Position) IsFixed

func (p *Position) IsFixed() bool

IsFixed is Position::is_fixed in velato src/runtime/model/animated.rs.

type PositionKeyframe

type PositionKeyframe struct {
	Keyframe

	ValueInTangent  []float64
	ValueOutTangent []float64
}

PositionKeyframe is PositionKeyframe in velato src/schema/animated_properties/position_keyframe.rs.

func (*PositionKeyframe) UnmarshalJSON

func (k *PositionKeyframe) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the keyframe and its spatial tangents.

type PositionKind

type PositionKind uint8

PositionKind is the variant of Position in velato src/runtime/model/animated.rs.

const (
	PositionValue PositionKind = iota
	PositionSplit
	PositionSpatial
)

The variants of Position.

type PositionSchema

type PositionSchema struct {
	PropertyIndex *float64
	Animated      *BoolInt
	Expression    *string
	Length        *float64
	Value         PositionValueK
}

PositionSchema is Position in velato src/schema/animated_properties/position.rs.

func (*PositionSchema) UnmarshalJSON

func (p *PositionSchema) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the position. The key "k" is required.

type PositionValueK

type PositionValueK struct {
	Keyframes  []PositionKeyframe
	Static     []float64
	IsAnimated bool
}

PositionValueK is PositionValueK in velato src/schema/animated_properties/position.rs: a list of keyframes, or a static value (D27).

func (*PositionValueK) UnmarshalJSON

func (k *PositionValueK) UnmarshalJSON(data []byte) error

UnmarshalJSON tries the keyframes first, then the static value.

type Precomposition

type Precomposition struct {
	Asset
	CompositionSchema

	FrameRate *float64 `json:"fr,omitempty"`
	Extra     *BoolInt `json:"xt,omitempty"`
}

Precomposition is Precomposition in velato src/schema/assets/precomposition.rs.

type PrecompositionLayer

type PrecompositionLayer struct {
	VisualLayer

	RefID     string      `json:"refId"`
	Width     float64     `json:"w"`
	Height    float64     `json:"h"`
	StartTime float64     `json:"st"`
	TimeRemap *FloatValue `json:"tm,omitempty"`
}

PrecompositionLayer is PrecompositionLayer in velato src/schema/layers/precomposition.rs.

type PuckerBloatShape

type PuckerBloatShape struct {
	ModifierShape

	Amount *FloatValue `json:"a,omitempty"`
}

PuckerBloatShape is PuckerBloatShape in velato src/schema/shapes/pucker_bloat.rs.

type Rect

type Rect = kurbo.Rect

Rect is kurbo::Rect.

type RectangleShape

type RectangleShape struct {
	ShapeSchema

	Position            PositionSchema   `json:"p"`
	Size                MultiDimensional `json:"s"`
	RoundedCornerRadius FloatValue       `json:"r"`
}

RectangleShape is RectangleShape in velato src/schema/shapes/rectangle.rs.

type Renderer

type Renderer struct {
	// MergePaths draws the merge paths of modes 2 to 5 as After Effects
	// combines them (D42). A fill of the result draws by compositing. A
	// stroke or a trim path of the result draws the path of the geometric
	// boolean operation (D94). It is false by default, because ThorVG and
	// velato draw a merge path as a compound path, and ThorVG is the
	// reference of the tests (D43).
	MergePaths bool
	// contains filtered or unexported fields
}

Renderer is Renderer in velato src/runtime/render.rs: it renders a composition onto a Sink.

func NewRenderer

func NewRenderer() *Renderer

NewRenderer is Renderer::new in velato src/runtime/render.rs.

func (*Renderer) Append

func (r *Renderer) Append(animation *Composition, frame float64, transform kurbo.Affine, alpha float64, sink Sink) error

Append is Renderer::try_append in velato src/runtime/render.rs: it renders the animation at frame onto sink. It returns the error of the evaluation, and then leaves sink unchanged.

Port: velato's append panics on an evaluation error. Go returns the error (D41).

func (*Renderer) AppendEvaluated

func (r *Renderer) AppendEvaluated(evaluated *EvaluatedComposition, transform kurbo.Affine, alpha float64, sink Sink)

AppendEvaluated is Renderer::append_evaluated in velato src/runtime/render.rs: it draws a saved evaluation.

type RepeaterComposite

type RepeaterComposite uint8

RepeaterComposite is RepeaterComposite in velato src/runtime/model/mod.rs: how repeater copies stack.

const (
	// RepeaterBelow paints later copies below earlier copies.
	RepeaterBelow RepeaterComposite = iota
	// RepeaterAbove paints later copies above earlier copies.
	RepeaterAbove
)

The values of RepeaterComposite.

type RepeaterShape

type RepeaterShape struct {
	ModifierShape

	Copies    FloatValue             `json:"c"`
	Offset    *FloatValue            `json:"o,omitempty"`
	Composite *Composite             `json:"m,omitempty"`
	Transform RepeaterTransformShape `json:"tr"`
}

RepeaterShape is RepeaterShape in velato src/schema/shapes/repeater.rs.

type RepeaterTransformShape

type RepeaterTransformShape struct {
	TransformShape

	StartOpacity *FloatValue `json:"so,omitempty"`
	EndOpacity   *FloatValue `json:"eo,omitempty"`
}

RepeaterTransformShape is RepeaterTransformShape in velato src/schema/shapes/repeater_transform.rs.

type RepeaterValue

type RepeaterValue struct {
	Fixed    FixedRepeater
	Animated *AnimatedRepeater
}

RepeaterValue is Repeater in velato src/runtime/model/mod.rs: a fixed or an animated repeater (D27).

func (RepeaterValue) Evaluate

func (r RepeaterValue) Evaluate(frame float64) FixedRepeater

Evaluate is Repeater::evaluate in velato src/runtime/model/mod.rs.

type RoundedCornersShape

type RoundedCornersShape struct {
	ModifierShape

	Radius FloatValue `json:"r"`
}

RoundedCornersShape is RoundedCornersShape in velato src/schema/shapes/rounded_corners.rs.

type Shape

type Shape struct {
	Kind ShapeKind
	// Group holds the shapes of a group, and GroupTransform its transform,
	// or nil.
	Group          []Shape
	GroupTransform *GroupTransform
	Geometry       Geometry
	Draw           Draw
	Repeater       RepeaterValue
	Trim           TrimValue
	// Merge is the mode of a merge path.
	Merge MergeMode
}

Shape is Shape in velato src/runtime/model/mod.rs: an element of a shape layer (D27).

type ShapeDirection

type ShapeDirection uint8

ShapeDirection is ShapeDirection in velato src/schema/constants/shape_direction.rs.

const (
	ShapeDirectionNormal   ShapeDirection = 1
	ShapeDirectionReversed ShapeDirection = 3
)

The values of ShapeDirection.

func (*ShapeDirection) UnmarshalJSON

func (d *ShapeDirection) UnmarshalJSON(data []byte) error

UnmarshalJSON reads 1 or 3.

type ShapeKeyframe

type ShapeKeyframe struct {
	Base  KeyframeBase
	Start []Bezier
	End   []Bezier
	// HasStart is true when the key "s" is present.
	HasStart bool
	HasEnd   bool
}

ShapeKeyframe is ShapeKeyframe in velato src/schema/animated_properties/shape_keyframe.rs.

func (*ShapeKeyframe) UnmarshalJSON

func (k *ShapeKeyframe) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the keyframe. The key "t" is required.

type ShapeKind

type ShapeKind uint8

ShapeKind is the variant of Shape in velato src/runtime/model/mod.rs.

const (
	ShapeGroup ShapeKind = iota
	ShapeGeometry
	ShapeDraw
	ShapeRepeater
	ShapeTrim
	// ShapeMerge is a merge path.
	//
	// Port: velato skips merge paths. okage keeps them, and draws those
	// that need a boolean operation by compositing (D42).
	ShapeMerge
)

The variants of Shape.

type ShapeLayer

type ShapeLayer struct {
	VisualLayer

	Shapes []AnyShape `json:"shapes"`
}

ShapeLayer is ShapeLayer in velato src/schema/layers/shape.rs.

type ShapeProperty

type ShapeProperty struct {
	PropertyIndex *float64
	Animated      *BoolInt
	Expression    *string
	Value         ShapePropertyK
}

ShapeProperty is ShapeProperty in velato src/schema/animated_properties/shape_property.rs.

func (*ShapeProperty) UnmarshalJSON

func (p *ShapeProperty) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the property. The key "k" is required.

type ShapePropertyK

type ShapePropertyK struct {
	Keyframes  []ShapeKeyframe
	Static     Bezier
	IsAnimated bool
}

ShapePropertyK is ShapePropertyK in velato src/schema/animated_properties/shape_property.rs: a list of keyframes, or a static Bezier (D27).

func (*ShapePropertyK) UnmarshalJSON

func (k *ShapePropertyK) UnmarshalJSON(data []byte) error

UnmarshalJSON tries the keyframes first, with the checks of deserialize_keyframes, then the static value.

type ShapeSchema

type ShapeSchema struct {
	GraphicElementShape

	Direction *ShapeDirection `json:"d,omitempty"`
}

ShapeSchema is Shape in velato src/schema/shapes/shape.rs.

type ShapeStyleShape

type ShapeStyleShape struct {
	GraphicElementShape

	Opacity FloatValue `json:"o"`
}

ShapeStyleShape is ShapeStyleShape in velato src/schema/shapes/shape_style.rs.

type Sink

type Sink interface {
	// PushLayer starts a layer that composites with blend and alpha, clipped
	// to shape under transform.
	PushLayer(blend BlendMode, alpha float32, transform kurbo.Affine, shape []kurbo.PathEl)
	// PushClipLayer starts a layer clipped to shape under transform.
	PushClipLayer(transform kurbo.Affine, shape []kurbo.PathEl)
	// PopLayer ends the last layer.
	PopLayer()
	// PushFilter starts a layer that applies effect, and returns
	// FilterPushed, or returns FilterUnsupported and starts no layer.
	PushFilter(transform kurbo.Affine, effect *FilterEffect) FilterLayerResult
	// Draw fills shape, or strokes it when stroke is not nil, with brush
	// under transform.
	Draw(stroke *Stroke, transform kurbo.Affine, brush *Brush, shape []kurbo.PathEl)
	// DrawImage draws a raster image asset.
	DrawImage(image *ImageAsset, transform kurbo.Affine, alpha float64)
	// BeginLayerGroup is called before a Lottie layer, with its name and
	// its index in its composition.
	BeginLayerGroup(name string, index int)
	// EndLayerGroup is called after a Lottie layer.
	EndLayerGroup()
}

Sink is the trait RenderSink in velato src/runtime/render.rs: what a Renderer draws onto. A shape is a list of path elements. A layer and a clip layer last until the PopLayer that matches them.

type SinkOption added in v0.19.0

type SinkOption func(*PixmapSink)

SinkOption is an option of a PixmapSink (D20).

func WithFS added in v0.19.0

func WithFS(fsys fs.FS) SinkOption

WithFS sets the files that the sink reads an image asset from, when the asset names a path and not a data URL. The path is the directory of the asset, its key u, followed by its file name, its key p, without a leading slash. DotLottie.FS gives the files of a dotLottie archive. Without this option, the sink draws nothing for such an asset. velato has no such field, because it leaves the images to the sink (D75).

func WithFontDatabase added in v0.19.0

func WithFontDatabase(db *svg.FontDatabase) SinkOption

WithFontDatabase sets the fonts that the sink draws the characters of a text layer with, when the list chars of the file does not hold their glyph. The sink takes the face whose PostScript name is the name of the font of the text document, or else the face of the family and the style of that font in the font list of the file. Without this option, such a character draws nothing, and the sink logs it to the logger of WithLogger. velato has no such field, because it does not draw text (D79).

func WithLogger added in v0.19.0

func WithLogger(l *slog.Logger) SinkOption

WithLogger sets the logger that the sink logs to, for an image asset that it cannot read or decode. Without this option, the sink logs nothing. velato has no such field (D20, D75).

func WithQuality added in v0.21.0

func WithQuality(quality int) SinkOption

WithQuality sets the quality of the Gaussian blurs and the drop shadows, from 0, the fastest, to 100, the best. The sink blurs as ThorVG does at that quality: with one box blur up to the quality 34, two up to 67, and three above. A value below 0 is 0, and a value above 100 is 100. Without this option, the quality is 50, the default of ThorVG. velato has no such field. The option follows the quality of tvg_lottie_animation_set_quality of ThorVG (D20, D94).

type Size

type Size = kurbo.Size

Size is kurbo::Size.

type SolidLayer

type SolidLayer struct {
	VisualLayer

	Width  float64 `json:"sw"`
	Height float64 `json:"sh"`
	Color  string  `json:"sc"`
}

SolidLayer is SolidLayer in velato src/schema/layers/solid.rs.

type SpatialKeyframe

type SpatialKeyframe struct {
	Time  Time
	Value kurbo.Point
	// Offset from this keyframe's position, or nil.
	OutTangent *kurbo.Vec2
	// Offset from the next position, stored on this keyframe, or nil.
	InTangent *kurbo.Vec2
}

SpatialKeyframe is SpatialKeyframe in velato src/runtime/model/position.rs.

type SpatialPosition

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

SpatialPosition is SpatialPosition in velato src/runtime/model/position.rs: a position that moves along the curves of its spatial tangents.

func NewSpatialPosition

func NewSpatialPosition(keyframes []SpatialKeyframe) *SpatialPosition

NewSpatialPosition is SpatialPosition::new in velato src/runtime/model/position.rs.

func (*SpatialPosition) Evaluate

func (s *SpatialPosition) Evaluate(frame float64) kurbo.Point

Evaluate is SpatialPosition::evaluate in velato src/runtime/model/position.rs.

type SplineKeyframeValues

type SplineKeyframeValues struct {
	Start []kurbo.Point
	End   []kurbo.Point
	// Port: whether the start and the end of this keyframe are closed
	// (D43).
	StartClosed, EndClosed bool
}

SplineKeyframeValues is SplineKeyframeValues in velato src/runtime/model/animated.rs. When End is nil, the next keyframe's start is used.

type SplitVector

type SplitVector struct {
	Split bool
	X     FloatValue
	Y     FloatValue
	Z     *FloatValue
}

SplitVector is SplitVector in velato src/schema/animated_properties/split_vector.rs.

func (*SplitVector) UnmarshalJSON

func (s *SplitVector) UnmarshalJSON(data []byte) error

UnmarshalJSON requires the keys "s", "x" and "y".

type StarType

type StarType uint8

StarType is StarType in velato src/schema/constants/star_type.rs.

const (
	StarTypeStar    StarType = 1
	StarTypePolygon StarType = 2
)

The values of StarType.

func (*StarType) UnmarshalJSON

func (s *StarType) UnmarshalJSON(data []byte) error

UnmarshalJSON reads 1 or 2.

Port: velato gives an error for another value. okage reads it as a star (D110).

type Stroke

type Stroke struct {
	Width      float64
	Join       Join
	MiterLimit float64
	StartCap   Cap
	EndCap     Cap
	// Dash holds the lengths of the dashes and the gaps, and DashOffset
	// the offset of the pattern, or Dash is nil for a solid stroke.
	//
	// Port: velato reads the dashes of a stroke, and does not use them.
	// okage dashes the stroke, as ThorVG does (D43).
	Dash       []float64
	DashOffset float64
}

Stroke is kurbo::Stroke, the style of a stroke, without dashes, which velato does not make.

type StrokeDashShape

type StrokeDashShape struct {
	VisualObject

	DashType *StrokeDashType `json:"n,omitempty"`
	Length   *FloatValue     `json:"v,omitempty"`
}

StrokeDashShape is StrokeDashShape in velato src/schema/shapes/stroke_dash.rs.

type StrokeDashType

type StrokeDashType string

StrokeDashType is StrokeDashType in velato src/schema/constants/stroke_dash_type.rs.

func (*StrokeDashType) UnmarshalJSON

func (s *StrokeDashType) UnmarshalJSON(data []byte) error

UnmarshalJSON reads "d", "g" or "o".

type StrokeShape

type StrokeShape struct {
	ShapeStyleShape
	BaseStrokeShape

	StrokeColor ColorValue `json:"c"`
}

StrokeShape is StrokeShape in velato src/schema/shapes/stroke.rs.

type StrokeValue

type StrokeValue struct {
	Fixed    Stroke
	Animated *AnimatedStroke
}

StrokeValue is Stroke in velato src/runtime/model/mod.rs: a fixed or an animated stroke (D27).

func (StrokeValue) Evaluate

func (s StrokeValue) Evaluate(frame float64) Stroke

Evaluate is Stroke::evaluate in velato src/runtime/model/mod.rs.

type TextAlignmentSchema added in v0.20.0

type TextAlignmentSchema struct {
	// Group is 1 for the characters, 2 for the words, 3 for the lines and 4
	// for all the text.
	Group  *int              `json:"g"`
	Anchor *MultiDimensional `json:"a"`
}

TextAlignmentSchema is the key m of a text layer: how the text animators group the glyphs, and the anchor point of a group.

type TextAnimation added in v0.20.0

type TextAnimation struct {
	// Animators are the text animators, in the order of the file.
	Animators []TextAnimator
	// Group is the grouping of the glyphs that turn about one point.
	Group TextGroup
	// Anchor is the point of a group that it turns about, in the units of
	// a glyph at the size 100.
	Anchor Value[kurbo.Point]
	// Path is the path of the text, or nil.
	Path *TextPath
}

TextAnimation holds the text animators of a text layer, the grouping of the glyphs that they change, and the path that the text follows (D85).

type TextAnimator added in v0.20.0

type TextAnimator struct {
	// Start, End and Offset give the range, in percent of the text, or in
	// glyphs when Index is true.
	Start, End, Offset Value[float64]
	Index              bool
	// Amount is the share of the style that the range gives, in percent.
	Amount Value[float64]
	// Smoothness softens the edge of the shape square, in percent.
	Smoothness Value[float64]
	// MinEase and MaxEase ease the share of each glyph, in percent.
	MinEase, MaxEase Value[float64]
	Based            TextBased
	Shape            TextSelectorShape

	// Position moves a glyph, in pixels.
	Position Value[kurbo.Point]
	// Scale scales a glyph, in percent.
	Scale Value[kurbo.Vec2]
	// Rotation turns the group of a glyph, in degrees.
	Rotation Value[float64]
	// Opacity, FillOpacity and StrokeOpacity are in percent.
	Opacity, FillOpacity, StrokeOpacity Value[float64]
	// FillColor, StrokeColor and StrokeWidth are nil when the animator
	// does not change them.
	FillColor, StrokeColor *Value[Color]
	StrokeWidth            *Value[float64]
	// Tracking adds space before a glyph, in the units of a glyph at the
	// size 100.
	Tracking Value[float64]
	// LineSpacing moves the next lines down, in pixels.
	LineSpacing Value[float64]
}

TextAnimator is a text animator: a range selector, and the style that it gives each glyph in proportion to the share of the glyph in the range.

type TextAnimatorSchema added in v0.20.0

type TextAnimatorSchema struct {
	Selector TextSelectorSchema `json:"s"`
	Style    TextStyleSchema    `json:"a"`
}

TextAnimatorSchema is a text animator of the key a of a text layer: a range selector that chooses the glyphs, and the style that it gives them (D85). The keys follow parseTextRange of ThorVG.

type TextBased added in v0.20.0

type TextBased uint8

TextBased is what a range selector counts, its key b.

const (
	TextBasedCharacters        TextBased = 1
	TextBasedCharactersNoSpace TextBased = 2
	TextBasedWords             TextBased = 3
	TextBasedLines             TextBased = 4
)

The values of TextBased. ThorVG counts the words as the number of the line plus the number of the spaces before the glyph.

type TextData added in v0.19.0

type TextData struct {
	Document  TextDocumentProperty `json:"d"`
	Animators []TextAnimatorSchema `json:"a"`
	Alignment *TextAlignmentSchema `json:"m"`
	Path      *TextPathSchema      `json:"p"`
}

TextData is the text of a text layer, its key t: the text document, the text animators, the grouping of their glyphs and the path of the text (D79, D85).

type TextDocument added in v0.19.0

type TextDocument struct {
	// Text is the text. A carriage return, a line feed or the character 3
	// starts a new line.
	Text string
	// Font is the name of the font, the key of Composition.Fonts.
	Font string
	// Size is the font size in pixels.
	Size float64
	// Justify is the share of the free space of a line on the left of the
	// line: 0 for the left, 0.5 for the center and 1 for the right.
	Justify float64
	// Caps is 1 when a small letter draws the glyph of its capital, and 2
	// when it draws it at 70 percent of the size (D85).
	Caps int
	// Tracking is the space after each glyph of the list chars, in
	// thousandths of an em. For a glyph that the sink shapes, it scales the
	// advance instead, as ThorVG does (D82).
	Tracking float64
	// LineHeight is the distance from one baseline to the next, in pixels.
	LineHeight float64
	// BaselineShift moves the baseline up, in pixels.
	BaselineShift float64
	// Fill is the color of the glyphs, and Stroke the color of their
	// outline, both opaque.
	Fill   Color
	Stroke Color
	// StrokeWidth is the width of the outline, in pixels. 0 is no outline.
	StrokeWidth float64
	// StrokeBelow draws the outline below the fill.
	StrokeBelow bool
	// BoxPosition and BoxSize are the box of a box text. BoxSize is zero
	// for a text without a box.
	BoxPosition kurbo.Point
	BoxSize     kurbo.Size
}

TextDocument is a text document of a text layer, at one keyframe.

type TextDocumentKeyframe added in v0.19.0

type TextDocumentKeyframe struct {
	Time     float64            `json:"t"`
	Document TextDocumentSchema `json:"s"`
}

TextDocumentKeyframe is a keyframe of a text document: the document from the frame Time on.

type TextDocumentProperty added in v0.19.0

type TextDocumentProperty struct {
	Keyframes []TextDocumentKeyframe `json:"k"`
}

TextDocumentProperty is the animated text document of a text layer, its key d. Each keyframe holds a whole document, and the documents do not blend.

func (*TextDocumentProperty) UnmarshalJSON added in v0.19.0

func (p *TextDocumentProperty) UnmarshalJSON(data []byte) error

UnmarshalJSON requires the key "k".

type TextDocumentSchema added in v0.19.0

type TextDocumentSchema struct {
	// Text is the text. A carriage return or the character 3 starts a new
	// line.
	Text string `json:"t"`
	// FontName is the name of the font, the key fName of an entry of the
	// font list.
	FontName string `json:"f"`
	// Size is the font size, in pixels.
	Size float64 `json:"s"`
	// Justify is 0 for the left, 1 for the right and 2 for the center.
	Justify int `json:"j"`
	// Caps is 0 for the text as it is, 1 for all capitals and 2 for small
	// capitals (D85).
	Caps int `json:"ca"`
	// Tracking is the space after each glyph, in thousandths of an em.
	Tracking float64 `json:"tr"`
	// LineHeight is the distance from one baseline to the next, in pixels.
	LineHeight float64 `json:"lh"`
	// BaselineShift moves the baseline up, in pixels.
	BaselineShift float64 `json:"ls"`
	// FillColor and StrokeColor are colors of red, green and blue, from 0 to
	// 1.
	FillColor   []float64 `json:"fc"`
	StrokeColor []float64 `json:"sc"`
	// StrokeWidth is the width of the stroke, in pixels. 0 is no stroke.
	StrokeWidth float64 `json:"sw"`
	// StrokeOverFill draws the stroke over the fill.
	StrokeOverFill *bool `json:"of"`
	// BoxPosition and BoxSize are the box of a box text. A text without
	// a box has no BoxSize.
	BoxPosition []float64 `json:"ps"`
	BoxSize     []float64 `json:"sz"`
}

TextDocumentSchema is a text document, as getValue(TextDocument&) of ThorVG reads it.

type TextGroup added in v0.20.0

type TextGroup uint8

TextGroup is the grouping of the glyphs of a text animator, the key g of the key m of a text layer.

const (
	TextGroupCharacters TextGroup = 1
	TextGroupWords      TextGroup = 2
	TextGroupLines      TextGroup = 3
	TextGroupAll        TextGroup = 4
)

The values of TextGroup. ThorVG gives each glyph a group of its own for TextGroupAll, as for TextGroupCharacters.

type TextKeyframe added in v0.19.0

type TextKeyframe struct {
	Frame    float64
	Document TextDocument
}

TextKeyframe is a text document from the frame Frame on.

type TextLayer added in v0.19.0

type TextLayer struct {
	VisualLayer

	Text TextData `json:"t"`
}

TextLayer is a text layer, ty 5.

type TextPath added in v0.20.0

type TextPath struct {
	Mask        int
	FirstMargin Value[float64]
}

TextPath is the path that a text follows: the mask of the layer with the index Mask, and the margin before the first glyph, in pixels.

type TextPathSchema added in v0.20.0

type TextPathSchema struct {
	Mask        *int        `json:"m"`
	FirstMargin *FloatValue `json:"f"`
}

TextPathSchema is the key p of a text layer: the mask whose path the text follows, and the margin before the first glyph. A text without a path has an empty object or no mask.

type TextSelectorSchema added in v0.20.0

type TextSelectorSchema struct {
	// Start, End and Offset give the range, in percent of the text or in
	// glyphs, as Units says.
	Start  *FloatValue `json:"s"`
	End    *FloatValue `json:"e"`
	Offset *FloatValue `json:"o"`
	// Amount is the share of the style that the range gives, in percent.
	Amount *FloatValue `json:"a"`
	// Smoothness softens the edge of the shape square, in percent.
	Smoothness *FloatValue `json:"sm"`
	// MaxEase and MinEase ease the share of each glyph, in percent.
	MaxEase *FloatValue `json:"xe"`
	MinEase *FloatValue `json:"ne"`
	// Based is 1 for the characters, 2 for the characters without the
	// spaces, 3 for the words and 4 for the lines.
	Based *int `json:"b"`
	// Shape is 1 for a square, 2 for a ramp up, 3 for a ramp down, 4 for a
	// triangle, 5 for a round shape and 6 for a smooth shape.
	Shape *int `json:"sh"`
	// Units is 1 for percent and 2 for glyphs.
	Units *int `json:"r"`
	// Random is 1 when the range starts at a random place.
	Random *int `json:"rn"`
}

TextSelectorSchema is the range selector of a text animator.

type TextSelectorShape added in v0.20.0

type TextSelectorShape uint8

TextSelectorShape is the shape of a range selector, its key sh.

const (
	TextShapeSquare   TextSelectorShape = 1
	TextShapeRampUp   TextSelectorShape = 2
	TextShapeRampDown TextSelectorShape = 3
	TextShapeTriangle TextSelectorShape = 4
	TextShapeRound    TextSelectorShape = 5
	TextShapeSmooth   TextSelectorShape = 6
)

The values of TextSelectorShape.

type TextStyleSchema added in v0.20.0

type TextStyleSchema struct {
	Position      *MultiDimensional `json:"p"`
	Scale         *MultiDimensional `json:"s"`
	Rotation      *FloatValue       `json:"r"`
	Opacity       *FloatValue       `json:"o"`
	FillColor     *ColorValue       `json:"fc"`
	FillOpacity   *FloatValue       `json:"fo"`
	StrokeColor   *ColorValue       `json:"sc"`
	StrokeOpacity *FloatValue       `json:"so"`
	StrokeWidth   *FloatValue       `json:"sw"`
	// Tracking is the space after each glyph, in the units of a glyph at
	// the size 100.
	Tracking *FloatValue `json:"t"`
	// LineSpacing moves the next lines down, in pixels.
	LineSpacing *FloatValue `json:"ls"`
}

TextStyleSchema is the style that a text animator gives its glyphs.

type Time

type Time struct {
	// Frame number.
	Frame float64
	// Easing tangent going into the next keyframe.
	InTangent *EasingHandle
	// Easing tangent leaving the current keyframe.
	OutTangent *EasingHandle
	// Whether it's a hold frame.
	Hold bool
}

Time is Time in velato src/runtime/model/value.rs: the time of a keyframe, as a frame number.

type Transform

type Transform struct {
	Fixed    kurbo.Affine
	Animated *AnimatedTransform
}

Transform is Transform in velato src/runtime/model/mod.rs: a fixed affine transform, or an animated one (D27).

func (Transform) Components

func (t Transform) Components(frame float64) (TransformComponents, bool)

Components is Transform::components in velato src/runtime/model/mod.rs: the authored components, or false for a matrix-only transform.

func (Transform) Evaluate

func (t Transform) Evaluate(frame float64) kurbo.Affine

Evaluate is Transform::evaluate in velato src/runtime/model/mod.rs.

func (Transform) IsFixed

func (t Transform) IsFixed() bool

IsFixed is Transform::is_fixed in velato src/runtime/model/mod.rs.

type TransformComponents

type TransformComponents struct {
	Anchor    kurbo.Point
	Position  kurbo.Point
	Scale     kurbo.Vec2
	Rotation  float64
	Skew      float64
	SkewAngle float64
}

TransformComponents is TransformComponents in velato src/runtime/model/mod.rs: the evaluated authored values of a transform.

func (TransformComponents) Matrix

func (c TransformComponents) Matrix() kurbo.Affine

Matrix is TransformComponents::matrix in velato src/runtime/model/mod.rs.

type TransformSchema

type TransformSchema struct {
	AnchorPoint *PositionSchema   `json:"a,omitempty"`
	Position    *AnyTransformP    `json:"p,omitempty"`
	Scale       *MultiDimensional `json:"s,omitempty"`
	Rotation    *AnyTransformR    `json:"r,omitempty"`
	Skew        *FloatValue       `json:"sk,omitempty"`
	SkewAxis    *FloatValue       `json:"sa,omitempty"`
	Opacity     *FloatValue       `json:"o,omitempty"`
}

TransformSchema is Transform in velato src/schema/helpers/transform.rs.

Port: Position is a pointer, because a struct that embeds TransformSchema cannot require the key "p" with a method of its own. The conversion reports a missing position as serde does.

type TransformShape

type TransformShape struct {
	GraphicElementShape
	TransformSchema
}

TransformShape is TransformShape in velato src/schema/shapes/transform.rs.

type TrimMode

type TrimMode uint8

TrimMode is TrimMode in velato src/runtime/model/mod.rs.

const (
	// TrimParallel applies the range to each contour (m: 1).
	TrimParallel TrimMode = iota
	// TrimSequential applies the range across the combined lengths (m: 2).
	TrimSequential
)

The values of TrimMode.

type TrimMultipleShapes

type TrimMultipleShapes uint8

TrimMultipleShapes is TrimMultipleShapes in velato src/schema/constants/trim_multiple_shapes.rs.

const (
	TrimMultipleShapesParallel   TrimMultipleShapes = 1
	TrimMultipleShapesSequential TrimMultipleShapes = 2
)

The values of TrimMultipleShapes.

func (*TrimMultipleShapes) UnmarshalJSON

func (t *TrimMultipleShapes) UnmarshalJSON(data []byte) error

UnmarshalJSON reads 1 or 2.

type TrimPathShape

type TrimPathShape struct {
	ModifierShape

	Start    FloatValue          `json:"s"`
	End      FloatValue          `json:"e"`
	Offset   FloatValue          `json:"o"`
	Multiple *TrimMultipleShapes `json:"m,omitempty"`
}

TrimPathShape is TrimPathShape in velato src/schema/shapes/trim_path.rs.

type TrimValue

type TrimValue struct {
	Fixed    FixedTrim
	Animated *AnimatedTrim
}

TrimValue is Trim in velato src/runtime/model/mod.rs: a fixed or an animated trim (D27).

func (TrimValue) Evaluate

func (t TrimValue) Evaluate(frame float64) FixedTrim

Evaluate is Trim::evaluate in velato src/runtime/model/mod.rs.

type TwistShape

type TwistShape struct {
	ModifierShape

	Angle    FloatValue     `json:"a"`
	Position PositionSchema `json:"p"`
}

TwistShape is TwistShape in velato src/schema/shapes/twist.rs.

type UnsupportedEffect

type UnsupportedEffect struct {
	Name       string
	EffectType *uint64
}

UnsupportedEffect is UnsupportedEffect in velato src/runtime/model/mod.rs.

type Value

type Value[T any] struct {
	Fixed    T
	Animated *Animated[T]
}

Value is Value in velato src/runtime/model/value.rs: a fixed or animated value (D27).

func (Value[T]) Evaluate

func (v Value[T]) Evaluate(frame float64) T

Evaluate is Value::evaluate in velato src/runtime/model/value.rs: the value at frame, or the zero value of T where an animated value has no keyframe.

func (Value[T]) EvaluateOr

func (v Value[T]) EvaluateOr(frame float64, def T) T

EvaluateOr is Value::evaluate_or in velato src/runtime/model/value.rs.

func (Value[T]) IsFixed

func (v Value[T]) IsFixed() bool

IsFixed is Value::is_fixed in velato src/runtime/model/value.rs.

type Vec2

type Vec2 = kurbo.Vec2

Vec2 is kurbo::Vec2.

type VisualLayer

type VisualLayer struct {
	LayerSchema

	MatteMode                *MatteMode        `json:"tt,omitempty"`
	MatteTarget              *BoolInt          `json:"td,omitempty"`
	MasksProperties          []MaskSchema      `json:"masksProperties,omitempty"`
	Effects                  []json.RawMessage `json:"ef,omitempty"`
	Transform                TransformSchema   `json:"ks"`
	RotateToMatchAnimPosPath *BoolInt          `json:"ao,omitempty"`
	MatteLayerIndex          *float64          `json:"tp,omitempty"`
	HasMask                  *bool             `json:"hasMask,omitempty"`
	MotionBlur               *bool             `json:"mb,omitempty"`
	BlendMode                *BlendModeSchema  `json:"bm,omitempty"`
	CSSClass                 *string           `json:"cl,omitempty"`
	ID                       *string           `json:"ln,omitempty"`
	TagName                  *string           `json:"tg,omitempty"`
	TransformBeforeMask      *BoolInt          `json:"ct,omitempty"`
}

VisualLayer is VisualLayer in velato src/schema/layers/visual.rs.

type VisualObject

type VisualObject struct {
	Name      *string `json:"nm,omitempty"`
	MatchName *string `json:"mn,omitempty"`
}

VisualObject is VisualObject in velato src/schema/helpers/visual_object.rs.

Jump to

Keyboard shortcuts

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