project

package
v0.0.0-...-b80cc47 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package project contains the firefly project structure

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalColor

func MarshalColor(c color.Color) []byte

func UnmarshalColor

func UnmarshalColor(raw []byte) (color.Color, error)

Types

type Audio

type Audio struct {
	Title  string     // title of the song
	Author string     // name of the interpret
	Genres []string   // genres of the song
	File   *AudioFile // the audio file
}

Audio contains everything about the audio of a project

type AudioFile

type AudioFile struct {
	Format string // the encoding format of the data
	Data   []byte // the audio data
}

AudioFile contains the (probably encoded) audio of the project

type Effect

type Effect struct {
	Beginning float64
	Ending    float64
}

Effect contains a visual effect that is applied on to the scene

type Element

type Element struct {
	ZIndex  float64     // a coordinate relative to other elements in the scene. Higher numbers will be drawn on top of lower ones
	Shape   shape.Shape // the actual visual shape of the element
	Pattern Pattern     // the pattern that fills the body of the element
}

An Element that is located at a specific point in time in the scene

func (*Element) Copy

func (e *Element) Copy() *Element

Copy returns a deep copy of the element

func (*Element) MapLocalToRelative

func (e *Element) MapLocalToRelative(local vectorpath.Point) vectorpath.Point

MapLocalToRelative maps local coordinates to relative coordinates.

Local coordinates are at (0,0) at the top left of the bounding box of the shape and (1,1) at the bottom right. Relative coordinates have their origin at the top left of the bounding box of the shape but their scale is the same as the scene.

func (*Element) MapRelativeToLocal

func (e *Element) MapRelativeToLocal(relative vectorpath.Point) vectorpath.Point

MapRelativeToLocal maps relative coordinates to local coordinates. See MapLocalToRelative for an explanation of the coordinates.

func (*Element) Mirror

func (e *Element) Mirror()

MirrorP mirrors this element on the P axis around the center of the scene

func (*Element) UnmarshalJSON

func (e *Element) UnmarshalJSON(data []byte) error

UnmarshalJSON will take data and try to parse it into an Element. It takes care of handling the Shape and Pattern interfaces with their respective Unmarshal functions.

type GradientAnchorPoint

type GradientAnchorPoint struct {
	color.Color
	vectorpath.Point
}

A GradientAnchorPoint contains a position and the color that position should have in the gradient

func (GradientAnchorPoint) Copy

func (GradientAnchorPoint) MarshalJSON

func (p GradientAnchorPoint) MarshalJSON() ([]byte, error)

func (*GradientAnchorPoint) UnmarshalJSON

func (p *GradientAnchorPoint) UnmarshalJSON(raw []byte) error

type GradientColorStep

type GradientColorStep struct {
	color.Color
	Position float64
}

GradientColorStep is a position on a gradient that has a specific color

func (GradientColorStep) MarshalJSON

func (s GradientColorStep) MarshalJSON() ([]byte, error)

func (*GradientColorStep) UnmarshalJSON

func (s *GradientColorStep) UnmarshalJSON(raw []byte) error

type LinearGradient

type LinearGradient struct {
	Start GradientAnchorPoint
	Stop  GradientAnchorPoint
	Steps []GradientColorStep // the steps between the anchor points
}

LinearGradient fills an element with a gradient between two points. The positions of the gradient are in local coordinates to the element, meaning that the top left position is (0,0) and the bottom right one is at (1,1).

func NewLinearGradient

func NewLinearGradient(a color.Color, b color.Color) *LinearGradient

NewLinearGradient creates a new LinearGradient with the given start and stop colors

func (*LinearGradient) Copy

func (g *LinearGradient) Copy() Pattern

func (*LinearGradient) MarshalJSON

func (g *LinearGradient) MarshalJSON() ([]byte, error)

func (*LinearGradient) MirrorP

func (g *LinearGradient) MirrorP()

func (*LinearGradient) Pattern

func (g *LinearGradient) Pattern() Pattern

Pattern implements the Pattern interface

type Moment

type Moment float64

A Moment represents a point in time in a project in seconds

type Pattern

type Pattern interface {
	json.Marshaler

	Pattern() Pattern // this is just here to distinguish Pattern from an empty interface
	MirrorP()         // mirrors the pattern on the P axis
	Copy() Pattern
}

Pattern describes how an element should be filled

func UnmarshalPattern

func UnmarshalPattern(raw []byte) (Pattern, error)

type Project

type Project struct {
	Title          string            // title of the project
	Author         string            // name of the project author
	Tags           []string          // tags of the project
	AdditionalInfo map[string]string // additional information about the project for future extensibility
	Duration       float64           // the duration of the project in seconds
	Scene          Scene             // the visual elements of the project
	Audio          Audio             // the audio of the project
	AudioOffset    float64           // the offset of the audio timeline from the visual timeline. This can be negative
}

Project contains everything needed to describe a firefly project

type Scene

type Scene struct {
	Elements []*Element
	Effects  []*Effect
}

Scene contains all the visual elements of a project

func (Scene) GetElementsAt

func (s Scene) GetElementsAt(time float64) []*Element

type SolidColor

type SolidColor struct {
	color.Color
}

SolidColor fills an element with a solid color

func NewSolidColor

func NewSolidColor(c color.Color) *SolidColor

NewSolidColor returns a new SolidColor Pattern with the specified color

func NewSolidColorRGBA

func NewSolidColorRGBA(r, g, b, a uint8) *SolidColor

NewSolidColorRGBA returns a new SolidColor Pattern with the color specified as r, g, b and a components in the range of [0,255]

func (*SolidColor) Copy

func (c *SolidColor) Copy() Pattern

func (*SolidColor) MarshalJSON

func (c *SolidColor) MarshalJSON() ([]byte, error)

func (*SolidColor) MirrorP

func (c *SolidColor) MirrorP()

func (*SolidColor) Pattern

func (c *SolidColor) Pattern() Pattern

Pattern implements the Pattern interface

func (*SolidColor) UnmarshalJSON

func (c *SolidColor) UnmarshalJSON(raw []byte) error

Directories

Path Synopsis
Package vectorpath contains definitions for shape paths
Package vectorpath contains definitions for shape paths

Jump to

Keyboard shortcuts

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