draw2dAnimation

package
Version: v0.0.0-...-6cb2204 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2014 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TopMargin int = iota
	BottomMargin
	LeftMargin
	RightMargin
)
View Source
const (
	None        updateType = iota
	Translation updateType = 1 << iota
	Rotation    updateType = 1 << iota
	Custom      updateType = 1 << iota
)
View Source
const (
	Unlimitted int = -1
)

Variables

View Source
var DestinationFolder string = "../result/"

A global variable holding the default destination for produces files.

View Source
var FrameHeight int = 480

A global variable holding the default height of the created frames.

View Source
var FramePattern string = "Frame"

A global variable holding the name of the produced frames which will be followed by their number.

View Source
var FrameWidth int = 640

A global variable holding the default width of the created frames.

Functions

func AddMusicToVideo

func AddMusicToVideo(videoPath string, musicPath string, outputPathAndFileName string, overwrite bool)

Add music to a video and the result is saved as a new file. All files should contain their extensions specified. Information source: http://blog.noizeramp.com/2011/04/21/adding-audio-track-to-video-with-ffmpeg/

func CreateVideo

func CreateVideo(inputDir string, outputPathAndFileName string, inputFps float64, outputFps float64, overwrite bool)

Creates video using FFmpeg and all of the frames with the global FramePattern in inputDir. Overwrite indicates whether the file should be replaces in case that such already exists in the destination folder.

func CreateVideoWithFrameStartNumber

func CreateVideoWithFrameStartNumber(inputDir string, outputPathAndFileName string, inputFps float64, outputFps float64, startNumber int, overwrite bool)

Creates video using FFmpeg and all of the frames with the global FramePattern in inputDir starting from StartNumber. Overwrite indicates whether the file should be replaces in case that such already exists in the destination folder. Information source: https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images

func ExecuteCustomFFMpegCommand

func ExecuteCustomFFMpegCommand(args string, input string)

Executes custom FFmpeg command by given arguments excluding the command name and input string if need. The ffmpeg.exe should be found in the %PATH% variable or in the current directory.

func GetTheImage

func GetTheImage() *image

Gets the singleton image.

func GetTheImageGraphicContext

func GetTheImageGraphicContext() *draw2d.ImageGraphicContext

Gets the singleton ImageGraphicContext.

Types

type Android

type Android struct {
	*ComposedFigure
	BodyWidth  float64
	BodyHeight float64
}

An adroid figure. Change width and height for adjusting the figure to the desired ratio.

func NewAndroid

func NewAndroid(bodyWidth float64, bodyHeight float64, lineWidth float64, fillColor color.RGBA) *Android

Constructor setting current struct's fields and default values for the base struct

func NewAndroid7

func NewAndroid7(
	bodyWidth float64, bodyHeight float64, fillColor color.RGBA,
	depth int, startPoint Point, rotationDegrees float64, lineWidth float64) *Android

Constructor setting both base struct's and current struct's fields.

func (*Android) InitializeFigures

func (this *Android) InitializeFigures(fillColor color.RGBA)

Called by constructors to set initial state of the figure. Can also be used for reset.

type Circle

type Circle struct {
	*Figure
	Radius float64
}

A figure type representing circle.

func NewCircle

func NewCircle(radius float64, lineWidth float64) *Circle

Constructor setting current struct's fields and default values for the base struct

func NewCircle4

func NewCircle4(radius float64, depth int, startPoint Point, lineWidth float64) *Circle

Constructor setting both base struct's and current struct's fields.

func (*Circle) Visualize

func (this *Circle) Visualize()

Defines the visualization of the figure according to position (0, 0).

type ComposedFigure

type ComposedFigure struct {
	*Figure
	// contains filtered or unexported fields
}

An abstract figure type. Represents a composition of figures kept as collection. Updates to this figure affect it as hole including each part.

func NewComposedFigure

func NewComposedFigure() *ComposedFigure

Constructor setting current struct's fields and default values for the base struct

func NewComposedFigure3

func NewComposedFigure3(depth int, startPoint Point, rotationDegrees float64) *ComposedFigure

Constructor setting both base struct's and current struct's fields.

func (*ComposedFigure) AddFigure

func (this *ComposedFigure) AddFigure(name string, figure Figurer)

Adds figure with string key to the contained collection.

func (*ComposedFigure) Draw

func (this *ComposedFigure) Draw()

Draw the figure by visualizing all its part taking in to account the scale, translation and rotation of the figure.

func (*ComposedFigure) GetFigureByName

func (this *ComposedFigure) GetFigureByName(name string) Figurer

Gets the figure corresponding to the given string key in the contained collection or nil if not found.

func (*ComposedFigure) RemoveFigure

func (this *ComposedFigure) RemoveFigure(name string)

Removes figure by string key from the contained collection.

func (*ComposedFigure) Update

func (this *ComposedFigure) Update()

Updates the figure as a whole and each of its parts.

func (*ComposedFigure) Visualize

func (this *ComposedFigure) Visualize()

Defines the visualization of the figure according to position (0, 0).

type Ellipsis

type Ellipsis struct {
	*Figure
	RadiusX float64
	RadiusY float64
}

A figure type representing ellipsis. Change RadiusX and RadiusY for adjusting the figure to the desired ratio.

func NewEllipsis

func NewEllipsis(radiusX float64, radiusY float64, lineWidth float64) *Ellipsis

Constructor setting current struct's fields and default values for the base struct

func NewEllipsis5

func NewEllipsis5(
	radiusX float64, radiusY float64, depth int, startPoint Point, rotationDegrees float64, lineWidth float64) *Ellipsis

Constructor setting both base struct's and current struct's fields.

func (*Ellipsis) Visualize

func (this *Ellipsis) Visualize()

Defines the visualization of the figure according to position (0, 0).

type Figure

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

An abstract figure type. Represents a base struct for all figures.

func NewFigure

func NewFigure() *Figure

Default constructor.

func NewFigure4

func NewFigure4(depth int, startPoint Point, rotationDegrees float64, lineWidth float64) *Figure

Constructor accepting depth(layer in the image), startPoint(to which all actions are related) and rotation degrees.

func (Figure) Draw

func (this Figure) Draw()

Draws the figure taking into account the translation, rotation and the rest common properties of all figures and using the implemented by the extending subClass Visualize() method.

func (*Figure) GetBase

func (this *Figure) GetBase() *Figure

Gets the current instance. Has meaning to be used from struct extending this one if need.

func (*Figure) GetDepth

func (this *Figure) GetDepth() int

Gets the depth(layer) of the figure in the image.

func (*Figure) GetFillColor

func (this *Figure) GetFillColor() color.RGBA

Gets the color used to fill the figure.

func (*Figure) GetIsFilled

func (this *Figure) GetIsFilled() bool

Gets whether the figure should be filled or stroked.

func (*Figure) GetLineWidth

func (this *Figure) GetLineWidth() float64

Gets the line width of the figure.

func (*Figure) GetRotationDegrees

func (this *Figure) GetRotationDegrees() float64

Get the current degrees by which the figure is rotated.

func (*Figure) GetScale

func (this *Figure) GetScale() Point

Gets the current scale ratio.

func (*Figure) GetStartPoint

func (this *Figure) GetStartPoint() Point

Gets the start point of the figure.

func (*Figure) GetStrokeColor

func (this *Figure) GetStrokeColor() color.RGBA

Gets to color used for drawing the contour of the figure.

func (*Figure) GetUpdateMethod

func (this *Figure) GetUpdateMethod() *UpdateMethod

Gets the update method used to update the figure on each call of Update().

func (*Figure) GetUpdateRotationDegrees

func (this *Figure) GetUpdateRotationDegrees() float64

Gets the degrees by which the figure rotates on each call of Update().

func (*Figure) GetUpdateTranslation

func (this *Figure) GetUpdateTranslation() Point

Gets the vector by which the figure is translated on each call of Update().

func (*Figure) SetDepth

func (this *Figure) SetDepth(value int)

Sets the depth(layer) of the figure in the image.

func (*Figure) SetFillColor

func (this *Figure) SetFillColor(value color.RGBA)

Sets the color to be used to fill the figure. Automatically set the figure as one to be filled.

func (*Figure) SetIsFilled

func (this *Figure) SetIsFilled(value bool)

Sets whether the figure should be filled or stroked.

func (*Figure) SetLineWidth

func (this *Figure) SetLineWidth(value float64)

Sets the line width of the figure.

func (*Figure) SetRotationDegrees

func (this *Figure) SetRotationDegrees(value float64)

Sets the rotation of the figure for the time after the next call of Update()

func (*Figure) SetScale

func (this *Figure) SetScale(value Point)

Sets the scale of the figure.

func (*Figure) SetStartPoint

func (this *Figure) SetStartPoint(value Point)

Sets the start point of the figure.

func (*Figure) SetStrokeColor

func (this *Figure) SetStrokeColor(value color.RGBA)

Sets the color to be used to draw the contour of the figure.

func (*Figure) SetSubClass

func (this *Figure) SetSubClass(value Figurer)

Sets the final figure in the extending chain. Should be called in the constructor of each extending struct. Has meaning to be used from struct extending this one to use function as virtual.

func (*Figure) SetUpdateMethod

func (this *Figure) SetUpdateMethod(value *UpdateMethod)

Sets the update method to be used for updating the figure on each call of Update(). A copy of the update method is used to avoid use of the same method by more than one figures.

func (*Figure) SetUpdateRotationDegrees

func (this *Figure) SetUpdateRotationDegrees(value float64)

Sets the degrees by which the figure should rotate on each call of Update().

func (*Figure) SetUpdateTranslation

func (this *Figure) SetUpdateTranslation(value Point)

Sets the vector by which the figure should translate on each call of Update().

func (*Figure) Update

func (this *Figure) Update()

Updates the figure by the update method, the update translation and the update rotation degrees.

type Figurer

type Figurer interface {
	GetDepth() int
	SetDepth(value int)
	GetStartPoint() Point
	SetStartPoint(value Point)
	GetRotationDegrees() float64
	SetRotationDegrees(value float64)
	GetFillColor() color.RGBA
	SetFillColor(value color.RGBA)
	GetStrokeColor() color.RGBA
	SetStrokeColor(value color.RGBA)
	GetIsFilled() bool
	SetIsFilled(value bool)
	GetLineWidth() float64
	SetLineWidth(value float64)
	GetScale() Point
	SetScale(value Point)
	GetUpdateTranslation() Point
	SetUpdateTranslation(value Point)
	GetUpdateRotationDegrees() float64
	SetUpdateRotationDegrees(value float64)
	GetUpdateMethod() *UpdateMethod
	SetUpdateMethod(value *UpdateMethod)
	Draw()
	Update()
	Visualize()
	// contains filtered or unexported methods
}

Represents the base interface of all figures. For information on the methods see struct Figure.

type Heart

type Heart struct {
	*Figure
	Width  float64
	Height float64
}

A figure type with the shape of a heart. Change width and height for adjusting the figure to the desired ratio.

func NewHeart

func NewHeart(width float64, height float64, lineWidth float64) *Heart

Constructor setting current struct's fields and default values for the base struct

func NewHeart6

func NewHeart6(
	width float64, height float64, depth int, startPoint Point, rotationDegrees float64, lineWidth float64) *Heart

Constructor setting both base struct's and current struct's fields.

func (*Heart) Visualize

func (this *Heart) Visualize()

Defines the visualization of the figure according to position (0, 0).

type Line

type Line struct {
	*Figure
	Length float64
}

A figure type representing a line.

func NewLine

func NewLine(length float64, width float64) *Line

Constructor setting current struct's fields and default values for the base struct

func NewLine5

func NewLine5(
	length float64, depth int, startPoint Point, rotationDegrees float64, width float64) *Line

Constructor setting both base struct's and current struct's fields.

func (*Line) Visualize

func (this *Line) Visualize()

Defines the visualization of the figure according to position (0, 0).

type Point

type Point struct {
	X float64
	Y float64
}

Represents a 2D point.

type Rectangle

type Rectangle struct {
	*Figure
	Width  float64
	Height float64
}

A figure type representing a rectangle. Change width and height for adjusting the figure to the desired ratio.

func NewRectangle

func NewRectangle(width float64, height float64, lineWidth float64) *Rectangle

Constructor setting current struct's fields and default values for the base struct

func NewRectangle6

func NewRectangle6(
	width float64, height float64, depth int, startPoint Point, rotationDegrees float64, lineWidth float64) *Rectangle

Constructor setting both base struct's and current struct's fields.

func (*Rectangle) GetHeight

func (this *Rectangle) GetHeight() float64

Gets the height of the rectangle.

func (*Rectangle) GetWidth

func (this *Rectangle) GetWidth() float64

Gets the width of the rectangle.

func (*Rectangle) SetHeight

func (this *Rectangle) SetHeight(value float64)

Sets the height of the rectangle.

func (*Rectangle) SetWidth

func (this *Rectangle) SetWidth(value float64)

Sets the width of the rectangle.

func (*Rectangle) Visualize

func (this *Rectangle) Visualize()

Defines the visualization of the figure according to position (0, 0).

type Rectangler

type Rectangler interface {
	Figurer
	GetWidth() float64
	SetWidth(value float64)
	GetHeight() float64
	SetHeight(value float64)
}

type RoundRectangle

type RoundRectangle struct {
	*Rectangle
	Radius float64
}

A figure type with the shape a rectangle with rounded edges. Change width, height and radius for adjusting the figure to the desired ratio.

func NewRoundRectangle

func NewRoundRectangle(radius float64, width float64, height float64, lineWidth float64) *RoundRectangle

Constructor setting current struct's fields and default values for the base struct

func NewRoundRectangle7

func NewRoundRectangle7(
	radius float64, width float64, height float64,
	depth int, startPoint Point, rotationDegrees float64, lineWidth float64) *RoundRectangle

Constructor setting both base struct's and current struct's fields.

func (*RoundRectangle) Visualize

func (this *RoundRectangle) Visualize()

Defines the visualization of the figure according to position (0, 0).

type Text

type Text struct {
	*Figure
	FontData draw2d.FontData
	FontSize float64
	Text     string
}

A figure type that allows visualization of a text with custom font. Change font size and data to adjust the text visulization.

func NewText

func NewText(fontData draw2d.FontData, fontSize float64, text string) *Text

Constructor setting current struct's fields and default values for the base struct

func NewText6

func NewText6(fontData draw2d.FontData, fontSize float64, text string,
	depth int, startPoint Point, rotationDegrees float64) *Text

Constructor setting both base struct's and current struct's fields.

func (*Text) Visualize

func (this *Text) Visualize()

Defines the visualization of the figure according to position (0, 0).

type TextWithFrame

type TextWithFrame struct {
	*ComposedFigure
	Margins []float64
}

func NewTextWithFrame

func NewTextWithFrame(fontData draw2d.FontData, fontSize float64, text string, margin float64,
	base *ComposedFigure) *TextWithFrame

Constructor accepting initialized base class and creating text with rectangular frame and equal margins for all sides.

func NewTextWithFrameCustomMargins

func NewTextWithFrameCustomMargins(fontData draw2d.FontData, fontSize float64, text string, margins []float64,
	base *ComposedFigure) *TextWithFrame

Constructor accepting initialized base class and creating text with rectangular frame and custom margin for each sides.

func NewTextWithRoundFrame

func NewTextWithRoundFrame(fontData draw2d.FontData, fontSize float64, text string, margin float64, radius float64,
	base *ComposedFigure) *TextWithFrame

Constructor accepting initialized base class and radius and creating text with rectangular frame with round edges and equal margins for all sides.

func NewTextWithRoundFrameCustomMargins

func NewTextWithRoundFrameCustomMargins(fontData draw2d.FontData, fontSize float64, text string, margins []float64, radius float64,
	base *ComposedFigure) *TextWithFrame

Constructor accepting initialized base class and radius and creating text with rectangular frame with round edges and custom margin for each sides.

type UpdateMethod

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

Type representing figure's update method than can set properties like expiration time, wait until starting, how often to update and a set of functions used for updating.

func NewUpdateMethod

func NewUpdateMethod(funcs ...func(Figurer)) *UpdateMethod

Creates new update method by given set of update functions.

func NewUpdateMethod2

func NewUpdateMethod2(times int, funcs ...func(Figurer)) *UpdateMethod

Creates new update method by given times to update and set of update functions.

func NewUpdateMethod3

func NewUpdateMethod3(times int, waitTimes int, funcs ...func(Figurer)) *UpdateMethod

Creates new update method by given times to update, wait time before updating and set of update functions.

func NewUpdateMethod4

func NewUpdateMethod4(times int, waitTimes int, eachNth int, funcs ...func(Figurer)) *UpdateMethod

Creates new update method by given times to update, wait time before updating, how often to update and set of update functions.

func (*UpdateMethod) Update

func (this *UpdateMethod) Update(figure Figurer)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL