flare

package
v0.0.0-...-097d1aa Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package flare provides read/write access to JSON flare files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Animation

type Animation struct {
	// AnimationEnd represents the end time of the animation.
	AnimationEnd *float64 `json:"animationEnd,omitempty"`

	// AnimationStart represents the start time of the animation.
	AnimationStart *float64 `json:"animationStart,omitempty"`

	// Duration represents the duration of the animation.
	Duration *float64 `json:"duration,omitempty"`

	// FPS is the frames per second rate of the animation.
	FPS *float64 `json:"fps,omitempty"`

	// IsLooping controls the looping of the animation.
	IsLooping *bool `json:"isLooping,omitempty"`

	// Keyed represents a list of keys for the animation.
	Keyed []*Key `json:"keyed,omitempty"`

	// Name represents the name of the animation.
	Name *string `json:"name,omitempty"`

	// Type is "animation".
	Type *string `json:"type,omitempty"`
}

Animation represents a flare animation.

func (*Animation) GetAnimationEnd

func (a *Animation) GetAnimationEnd() float64

GetAnimationEnd returns the AnimationEnd field if it's non-nil, zero value otherwise.

func (*Animation) GetAnimationStart

func (a *Animation) GetAnimationStart() float64

GetAnimationStart returns the AnimationStart field if it's non-nil, zero value otherwise.

func (*Animation) GetDuration

func (a *Animation) GetDuration() float64

GetDuration returns the Duration field if it's non-nil, zero value otherwise.

func (*Animation) GetFPS

func (a *Animation) GetFPS() float64

GetFPS returns the FPS field if it's non-nil, zero value otherwise.

func (*Animation) GetIsLooping

func (a *Animation) GetIsLooping() bool

GetIsLooping returns the IsLooping field if it's non-nil, zero value otherwise.

func (*Animation) GetName

func (a *Animation) GetName() string

GetName returns the Name field if it's non-nil, zero value otherwise.

func (*Animation) GetType

func (a *Animation) GetType() string

GetType returns the Type field if it's non-nil, zero value otherwise.

type Artboard

type Artboard struct {
	// Animations represents a list of flare animations.
	Animations []*Animation `json:"animations,omitempty"`

	// ClipContents controls clipping of contents.
	ClipContents *bool `json:"clipContents,omitempty"`

	// Color represents a flare RGBA color (0-1).
	Color *Color `json:"color,omitempty"`

	// Height represents a height.
	Height *float64 `json:"height,omitempty"`

	// Name represents an artboard name.
	Name *string `json:"name,omitempty"`

	// Nodes represents a list of flare nodes.
	Nodes []*Node `json:"nodes,omitempty"`

	// Origin represents a flare origin.
	Origin []float64 `json:"origin,omitempty"`

	// Translation represents a flare translation.
	Translation []float64 `json:"translation,omitempty"`

	// Type is "artboard".
	Type *string `json:"type,omitempty"`

	// Width represents a width.
	Width *float64 `json:"width,omitempty"`
}

Artboard represents a flare artboard.

func (*Artboard) GetClipContents

func (a *Artboard) GetClipContents() bool

GetClipContents returns the ClipContents field if it's non-nil, zero value otherwise.

func (*Artboard) GetColor

func (a *Artboard) GetColor() *Color

GetColor returns the Color field.

func (*Artboard) GetHeight

func (a *Artboard) GetHeight() float64

GetHeight returns the Height field if it's non-nil, zero value otherwise.

func (*Artboard) GetName

func (a *Artboard) GetName() string

GetName returns the Name field if it's non-nil, zero value otherwise.

func (*Artboard) GetType

func (a *Artboard) GetType() string

GetType returns the Type field if it's non-nil, zero value otherwise.

func (*Artboard) GetWidth

func (a *Artboard) GetWidth() float64

GetWidth returns the Width field if it's non-nil, zero value otherwise.

type BlendModeType

type BlendModeType int

BlendModeType controls the blend mode of the node.

const (
	BlendModeType3 BlendModeType = 3 // TODO: figure these out.
)

type Bone

type Bone struct {
}

Bone represents a flare bone.

type Color

type Color [4]float64

Color represents a flare RGBA color (0-1).

type InterpolatorType

type InterpolatorType int

InterpolatorType controls the type of interpolation used by a key.

const (
	InterpolatorType1 InterpolatorType = 1 // TODO: figure these out.
)

type Key

type Key struct {
	// Component is the component that this key affects.
	Component *int `json:"component,omitempty"`

	// Opacity is a 2D array of opacity keys.
	Opacity [][]*KeyNode `json:"opacity,omitempty"`

	// PathVertices is a 2D array of pathVertices keys.
	PathVertices [][]*KeyNode `json:"pathVertices,omitempty"`

	// PosX is a 2D array of position keys.
	PosX [][]*KeyNode `json:"posX,omitempty"`

	// PosY is a 2D array of position keys.
	PosY [][]*KeyNode `json:"posY,omitempty"`

	// Rotation is a 2D array of rotation keys.
	Rotation [][]*KeyNode `json:"rotation,omitempty"`

	// ScaleX is a 2D array of scale keys.
	ScaleX [][]*KeyNode `json:"scaleX,omitempty"`

	// ScaleY is a 2D array of scale keys.
	ScaleY [][]*KeyNode `json:"scaleY,omitempty"`
}

Key represents an animation key in flare.

func (*Key) GetComponent

func (k *Key) GetComponent() int

GetComponent returns the Component field if it's non-nil, zero value otherwise.

type KeyNode

type KeyNode struct {
	// CubicX1 controls the scale key.
	CubicX1 *float64 `json:"cubicX1,omitempty"`

	// CubicX2 controls the scale key.
	CubicX2 *float64 `json:"cubicX2,omitempty"`

	// CubicY1 controls the scale key.
	CubicY1 *float64 `json:"cubicY1,omitempty"`

	// CubicY2 controls the scale key.
	CubicY2 *float64 `json:"cubicY2,omitempty"`

	// InterpolatorType controls the interpolation type of the key.
	InterpolatorType *InterpolatorType `json:"interpolatorType,omitempty"`

	// Time is the key time.
	Time *float64 `json:"time,omitempty"`

	// Value is the key value or array of values.
	Value interface{} `json:"value,omitempty"`
}

KeyNode is a single key node.

func (*KeyNode) GetCubicX1

func (k *KeyNode) GetCubicX1() float64

GetCubicX1 returns the CubicX1 field if it's non-nil, zero value otherwise.

func (*KeyNode) GetCubicX2

func (k *KeyNode) GetCubicX2() float64

GetCubicX2 returns the CubicX2 field if it's non-nil, zero value otherwise.

func (*KeyNode) GetCubicY1

func (k *KeyNode) GetCubicY1() float64

GetCubicY1 returns the CubicY1 field if it's non-nil, zero value otherwise.

func (*KeyNode) GetCubicY2

func (k *KeyNode) GetCubicY2() float64

GetCubicY2 returns the CubicY2 field if it's non-nil, zero value otherwise.

func (*KeyNode) GetInterpolatorType

func (k *KeyNode) GetInterpolatorType() *InterpolatorType

GetInterpolatorType returns the InterpolatorType field.

func (*KeyNode) GetTime

func (k *KeyNode) GetTime() float64

GetTime returns the Time field if it's non-nil, zero value otherwise.

type Node

type Node struct {
	// BlendMode is a node.
	BlendMode *BlendModeType `json:"blendMode,omitempty"`

	// Bones is a list of bones.
	// Note that the pointer to the slice is needed in this
	// case to preserve the case where an empty list is
	// in the original flare file.
	Bones *[]*Bone `json:"bones,omitempty"`

	// Cap is a cap value.
	Cap *float64 `json:"cap,omitempty"`

	// Clips is a list of clips.
	// Note that the pointer to the slice is needed in this
	// case to preserve the case where an empty list is
	// in the original flare file.
	Clips *[]int `json:"clips,omitempty"`

	// Color is an RGBA color.
	Color *Color `json:"color,omitempty"`

	// ColorStops is a list of colorStops.
	ColorStops []float64 `json:"colorStops,omitempty"`

	// DrawOrder is the node's draw order.
	DrawOrder *int `json:"drawOrder,omitempty"`

	// End is an end value.
	End []float64 `json:"end,omitempty"`

	// FillRule is a fill rule.
	FillRule *int `json:"fillRule,omitempty"`

	// Height is a height value.
	Height *float64 `json:"height,omitempty"`

	// IsClosed controls the closed state of the node.
	IsClosed *bool `json:"isClosed,omitempty"`

	// IsCollapsed controls the collapsed state of the node.
	IsCollapsed *bool `json:"isCollapsed,omitempty"`

	// IsVisible contols the visibility of the node.
	IsVisible *bool `json:"isVisible,omitempty"`

	// Join is a join value.
	Join *float64 `json:"join,omitempty"`

	// Name is the node name.
	Name *string `json:"name,omitempty"`

	// NumColorStops is the number of color stops.
	NumColorStops *int `json:"numColorStops,omitempty"`

	// Opacity is an opacity.
	Opacity *float64 `json:"opacity,omitempty"`

	// Parent is the parent node number.
	Parent *int `json:"parent,omitempty"`

	// Points is a list of points for the node.
	Points []*Point `json:"points,omitempty"`

	// Rotation is a rotation.
	Rotation *float64 `json:"rotation,omitempty"`

	// Scale is a 2D scale.
	Scale []float64 `json:"scale,omitempty"`

	// SecondaryRadiusScale is a secondary radius scale.
	SecondaryRadiusScale *float64 `json:"secondaryRadiusScale,omitempty"`

	// Start is a start value.
	Start []float64 `json:"start,omitempty"`

	// Translation is a 2D translation.
	Translation []float64 `json:"translation,omitempty"`

	// Trim is a trim value.
	Trim *float64 `json:"trim,omitempty"`

	// Type is the node type.
	Type *NodeType `json:"type,omitempty"`

	// Width is a width value.
	Width *float64 `json:"width,omitempty"`
}

Node represents a flare node.

func (*Node) GetBlendMode

func (n *Node) GetBlendMode() *BlendModeType

GetBlendMode returns the BlendMode field.

func (*Node) GetCap

func (n *Node) GetCap() float64

GetCap returns the Cap field if it's non-nil, zero value otherwise.

func (*Node) GetClips

func (n *Node) GetClips() []int

GetClips returns the Clips field if it's non-nil, zero value otherwise.

func (*Node) GetColor

func (n *Node) GetColor() *Color

GetColor returns the Color field.

func (*Node) GetDrawOrder

func (n *Node) GetDrawOrder() int

GetDrawOrder returns the DrawOrder field if it's non-nil, zero value otherwise.

func (*Node) GetFillRule

func (n *Node) GetFillRule() int

GetFillRule returns the FillRule field if it's non-nil, zero value otherwise.

func (*Node) GetHeight

func (n *Node) GetHeight() float64

GetHeight returns the Height field if it's non-nil, zero value otherwise.

func (*Node) GetIsClosed

func (n *Node) GetIsClosed() bool

GetIsClosed returns the IsClosed field if it's non-nil, zero value otherwise.

func (*Node) GetIsCollapsed

func (n *Node) GetIsCollapsed() bool

GetIsCollapsed returns the IsCollapsed field if it's non-nil, zero value otherwise.

func (*Node) GetIsVisible

func (n *Node) GetIsVisible() bool

GetIsVisible returns the IsVisible field if it's non-nil, zero value otherwise.

func (*Node) GetJoin

func (n *Node) GetJoin() float64

GetJoin returns the Join field if it's non-nil, zero value otherwise.

func (*Node) GetName

func (n *Node) GetName() string

GetName returns the Name field if it's non-nil, zero value otherwise.

func (*Node) GetNumColorStops

func (n *Node) GetNumColorStops() int

GetNumColorStops returns the NumColorStops field if it's non-nil, zero value otherwise.

func (*Node) GetOpacity

func (n *Node) GetOpacity() float64

GetOpacity returns the Opacity field if it's non-nil, zero value otherwise.

func (*Node) GetParent

func (n *Node) GetParent() int

GetParent returns the Parent field if it's non-nil, zero value otherwise.

func (*Node) GetRotation

func (n *Node) GetRotation() float64

GetRotation returns the Rotation field if it's non-nil, zero value otherwise.

func (*Node) GetSecondaryRadiusScale

func (n *Node) GetSecondaryRadiusScale() float64

GetSecondaryRadiusScale returns the SecondaryRadiusScale field if it's non-nil, zero value otherwise.

func (*Node) GetTrim

func (n *Node) GetTrim() float64

GetTrim returns the Trim field if it's non-nil, zero value otherwise.

func (*Node) GetType

func (n *Node) GetType() *NodeType

GetType returns the Type field.

func (*Node) GetWidth

func (n *Node) GetWidth() float64

GetWidth returns the Width field if it's non-nil, zero value otherwise.

type NodeType

type NodeType string

NodeType represents the node type.

const (
	// NodeTypeColorFill is a node type.
	NodeTypeColorFill NodeType = "colorFill"
	// NodeTypeColorStroke is a node type.
	NodeTypeColorStroke NodeType = "colorStroke"
	// NodeTypeEllipse is a node type.
	NodeTypeEllipse NodeType = "ellipse"
	// NodeTypeNode is a node type.
	NodeTypeNode NodeType = "node"
	// NodeTypePath is a node type.
	NodeTypePath NodeType = "path"
	// NodeTypeRadialGradientFill is a node type.
	NodeTypeRadialGradientFill NodeType = "radialGradientFill"
	// NodeTypeShape is a node type.
	NodeTypeShape NodeType = "shape"
)

type Point

type Point struct {
	// In is a list of in values.
	In []float64 `json:"in,omitempty"`

	// Out is a list of out values.
	Out []float64 `json:"out,omitempty"`

	// PointType is the point type.
	PointType *PointType `json:"pointType,omitempty"`

	// Radius is the radius of the point.
	Radius *float64 `json:"radius,omitempty"`

	// Translation is the translation of the point.
	Translation []float64 `json:"translation,omitempty"`
}

Point represents a flare point

func (*Point) GetPointType

func (p *Point) GetPointType() *PointType

GetPointType returns the PointType field.

func (*Point) GetRadius

func (p *Point) GetRadius() float64

GetRadius returns the Radius field if it's non-nil, zero value otherwise.

type PointType

type PointType int

PointType represents the point type.

type Root

type Root struct {
	// Artboards represents a list of flare artboards.
	Artboards []*Artboard `json:"artboards,omitempty"`

	// Version represents a flare version.
	Version *int `json:"version,omitempty"`
}

Root represents a flare top-level JSON blob.

func New

func New(buf []byte) (*Root, error)

New returns a new Root from the provided JSON blob.

func NewFile

func NewFile(filename string) (*Root, error)

NewFile parses the provided filename and returns a new Root.

func (*Root) GetVersion

func (r *Root) GetVersion() int

GetVersion returns the Version field if it's non-nil, zero value otherwise.

func (*Root) WriteFile

func (a *Root) WriteFile(filename string) error

WriteFile writes an Root as a JSON blob to the named file.

Jump to

Keyboard shortcuts

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