Public functions

Javis.ActionType
Action

Defines what is drawn in a defined frame range.

Fields

  • frames::Frames: A range of frames for which the Action is called
  • id::Union{Nothing, Symbol}: An id which can be used to save the result of func
  • func::Function: The drawing function which draws something on the canvas. It gets called with the arguments video, action, frame
  • anim::Animation: defines the interpolation function for the transitions
  • transitions::Vector{Transition} a list of transitions which can be performed before the function gets called.
  • internal_transitions::Vector{InternalTransition}: Similar to transitions but holds the concrete information whereas Transition can hold links to other actions which need to be computed first. See compute_transition!
  • opts::Any can hold any options defined by the user
  • change_keywords::Vector{Pair}
source
Javis.ActionMethod
Action(frames, func::Function, args...)

The most simple form of an action (if there are no args/kwargs) just calls func(video, action, frame) for each of the frames it is defined for. args are defined it the next function definition and can be seen in action in this example javis

source
Javis.ActionMethod
Action(frames, id::Union{Nothing,Symbol}, func::Function,
       transitions::Transition...; kwargs...)

Arguments

  • frames: defines for which frames this action is called
  • id::Symbol: Is used if the func returns something which shall be accessible by other actions later
  • func::Function the function that is called after the transitions are performed
  • transitions::Transition... a list of transitions that are performed before the function func itself is called

The keywords arguments will be saved inside .opts as a Dict{Symbol, Any}

source
Javis.ActionMethod
Action(frames, id::Union{Nothing,Symbol}, func::Function, easing::Union{ReversedEasing, Easing},
       args...; kwargs...)

Fallback constructor for an Action which does define an animation using an easing function.

Example

javis(
    video, [
        BackgroundAction(1:100, ground),
        Action((args...)->t(), sineio(), Translation(250, 0))
    ]
)
source
Javis.ActionMethod
Action(frames, id::Union{Nothing,Symbol}, func::Function,
       transitions::Transition...; kwargs...)

Fallback constructor for an Action which doesn't define an animation. A linear animation is assumed.

source
Javis.ActionMethod
Action(func::Function, args...)

Similar to the above but uses the same frames as the action above.

source
Javis.ActionMethod
Action(frames_or_id::Symbol, func::Function, args...)

This function decides whether you wrote Action(frames_symbol, ...), or Action(id_symbol, ...) If the symbol frames_or_id is not a FRAMES_SYMBOL then it is used as an id_symbol.

source
Javis.LineType
Line

A type to define a line by two points. Can be used i.e. in projection We mean the mathematic definition of a continuous line and not a segment of a line.

Fields

  • p1::Point: start point
  • p2::Point: second point to define the line
source
Javis.RelType
Rel

Ability to define frames in a relative fashion.

Example

 Action(1:100, ground; in_global_layer=true),
 Action(1:90, :red_ball, (args...)->circ(p1, "red"), Rotation(from_rot, to_rot)),
 Action(Rel(10), :blue_ball, (args...)->circ(p2, "blue"), Rotation(2π, from_rot, :red_ball)),
 Action((video, args...)->path!(path_of_red, pos(:red_ball), "red"))

is the same as

Action(1:100, ground; in_global_layer=true),
Action(1:90, :red_ball, (args...)->circ(p1, "red"), Rotation(from_rot, to_rot)),
Action(91:100, :blue_ball, (args...)->circ(p2, "blue"), Rotation(2π, from_rot, :red_ball)),
Action(91:100, (video, args...)->path!(path_of_red, pos(:red_ball), "red"))

Fields

  • rel::UnitRange defines the frames in a relative fashion.
source
Javis.RotationType
Rotation <: Transition

Stores the rotation similar to Translation with from and to but also the rotation point.

Fields

  • from::Union{Float64, Symbol}: The start rotation or a link to it
  • to::Union{Float64, Symbol}: The end rotation or a link to it
  • center::Union{Point, Symbol}: The center of the rotation or a link to it.
source
Javis.RotationMethod
Rotation(from, to)

Rotation as a transition from from to to (in radians) around the origin.

source
Javis.RotationMethod
Rotation(r::Union{Float64, Symbol}, center::Union{Point, Symbol})

Rotation as a transition from 0.0 to r around center. Can be used as a short-hand for rotating around a center point.

source
Javis.RotationMethod
Rotation(r::Union{Float64, Symbol})

Rotation as a transition from 0.0 to r . Can be used as a short-hand.

source
Javis.ScalingType
Scaling <: Transition

Stores the scaling similar to Translation with from and to.

Example

  • Can be called with different constructors like:
Scaling(10) -> Scaling(CURRENT_SCALING, (10.0, 10.0))
Scaling(10, :my-scale) -> Scaling((10.0, 10.0), :my_scale)
Scaling(10, 2) -> Scaling((10.0, 10.0), (2.0, 2.0))
Scaling(10, (1,2)) -> Scaling((10.0, 10.0), (1.0, 2.0))

Fields

  • from::Union{Tuple{Float64, Float64}, Symbol}: The start scaling or a link to it
  • to::Union{Tuple{Float64, Float64}, Symbol}: The end scaling or a link to it
  • compute_from_once::Bool: Saves whether the from is computed for the first frame or every frame. Is true if from is :_current_scale.
source
Javis.SubActionType
SubAction <: AbstractAction

A SubAction can be used in the keyword arguments of an Action to define small sub actions on the action function, such as appear.

A SubAction should not be created by hand but instead by using one of the constructors.

Fields

  • frames::Frames: the frames relative to the parent Action
  • anim::Animation: defines the interpolation function for the transitions
  • func::Function: the function that gets called in each of those frames. Takes the following arguments: video, action, subaction, rel_frame
  • transitions::Vector{Transition}: A list of transitions like Translation
  • internal_transitions::Vector{InternalTransition}: A list of internal transitions which store the current transition for a specific frame.
  • defs::Dict{Symbol, Any} any kind of definitions that are relevant for the subaction.
source
Javis.SubActionMethod
SubAction(frames, func::Function)

A SubAction can be defined with frames and a function inside the subactions kwarg of an Action. In the following example a filled circle with radius 50 appears in the first 20 frames, which means the opacity is increased from 0 to 1.0. Then it stays at full opacity and disappears the same way in the last 20 frames.

Example

javis(demo, [ BackgroundAction(1:100, ground), Action((args...)->circle(O, 50, :fill); subactions = [ SubAction(1:20, appear(:fade)), SubAction(81:100, disappear(:fade)) ]) ])

Arguments

  • frames: A list of frames for which the function should be called.
    • The frame numbers are relative to the parent Action.
  • func::Function: The function that gets called for the frames.
    • Needs to have four arguments: video, action, subaction, rel_frame
    • For appear and disappear a closure exists, such that appear(:fade) works.
source
Javis.SubActionMethod
SubAction(frames, easing::Union{ReversedEasing, Easing}, args...)

A SubAction can be defined with frames an easing function and either a function or transformation(s).

Example

In the following example a filled circle with radius 50 appears in the first 20 frames, which means the opacity is increased from 0 to 1.0. The interpolation function used here is sineio from Animations.jl. Then it stays at full opacity and disappears the same way in the last 20 frames using a linear decay.

javis(demo, [
    BackgroundAction(1:100, ground),
    Action((args...)->circle(O, 50, :fill); subactions = [
        SubAction(1:20, sineio(), appear(:fade)),
        SubAction(81:100, disappear(:fade))
    ])
])

Arguments

  • frames: A list of frames for which the function should be called.
    • The frame numbers are relative to the parent Action.
  • easing::Union{ReversedEasing, Easing}: The easing function for args...
  • args...: Either a function like appear or a Transformation like Translation
source
Javis.SubActionMethod
SubAction(frames, trans::Transition...)

A SubAction can also be defined this way with having a list of transitions. This is similar to defining transitions inside Action

In the following example a circle is faded in during the first 25 frames then moves to

  • Point(100, 20) then to Point(120, -20) (the translations are added)
  • and then back to the origin

In the last 25 frames it disappears from the world.

Example

javis(demo, [
        BackgroundAction(1:200, ground_opacity),
        Action((args...)->circle(O, 50, :fill); subactions = [
            SubAction(1:25, appear(:fade)),
            SubAction(26:75, Translation(Point(100, 20))),
            SubAction(76:100, Translation(Point(20, -40))),
            SubAction(101:175, Translation(Point(-120, 20))),
            SubAction(176:200, disappear(:fade))
        ]),
    ], tempdirectory="current/images", pathname="current/circle_square.gif")

Arguments

  • frames: A list of frames for which the function should be called.
    • The frame numbers are relative to the parent Action.
  • trans::Transition...: A list of transitions that shall be performed.
source
Javis.TransformationType
Transformation

Defines a transformation which can be returned by an action to be accessible later. See the circ function inside the javis as an example.

It can be accessed by another [Action])(@ref) using the symbol notation like :red_ball in the example.

Fields

  • p::Point: the translation part of the transformation
  • angle::Float64: the angle component of the transformation (in radians)
source
Javis.TranslationType
Translation <: Transition

Stores the Point or a link for the start and end position of the translation

Fields

from::Union{Point, Symbol}: The start position or a link to the start position. See :red_ball in javis to::Union{Point, Symbol}: The end position or a link to the end position

source
Javis.TranslationMethod
Translation(x::Real, y::Real)

Create a Translation(O, Point(x,y)) such that a translation is done from the origin. Shorthand for writing Translation(Point(x,y)).

source
Javis.TranslationMethod
Translation(p::Union{Point, Symbol})

Create a Translation(O, p) such that a translation is done from the origin.

source
Javis.VideoType
Video

Defines the video canvas for an animation.

Fields

  • width::Int the width in pixel
  • height::Int the height in pixel
  • defs::Dict{Symbol, Any} Some definitions which should be accessible throughout the video.
source
Javis.VideoMethod
Video(width, height)

Create a video with a certain width and height in pixel. This also sets CURRENT_VIDEO.

source
Base.:*Method
Base.:*(m::Array{Float64,2}, transformation::Transformation)

Convert the transformation to a matrix and multiplies m*trans_matrix. Return a new Transformation

source
Javis.BackgroundActionMethod
BackgroundAction(frames, func::Function, args...; kwargs...)

Create an Action where in_global_layer is set to true such that i.e the specified color in the background is applied globally (basically a new default)

source
Javis.BackgroundActionMethod
BackgroundAction(frames, id::Symbol, func::Function, args...; kwargs...)

Create an Action where in_global_layer is set to true and saves the return into id.

source
Javis.appearMethod
appear(s::Symbol)

Appear can be used inside a SubAction

Example

Action(101:200, (args...)->house_of_nicholas(); subactions = [
    SubAction(1:20, appear(:fade)),
    SubAction(81:100, disappear(:fade))
])

In this case the house_of_nicholas will fade in during the first 20 frames of the Action so 101-120.

Arguments

  • s::Symbol: the symbol defines the animation of appearance The only symbols that are currently supported are:
    • :fade_line_width which increases the line width up to the default value or the value specified by setline
    • :fade which increases the opcacity up to the default value or the value specified by setopacity
    • :scale which increases the scale up to the default value 1 or the value specified by scale
    • :draw_text which only works for text and lets it appear from left to right.
source
Javis.changeMethod
change(s::Symbol, [vals::Pair])

Changes the keyword s of the parent Action from vals[1] to vals[2] in an animated way.

Arguments

  • s::Symbol Change the keyword with the name s
  • vals::Pair If vals is given i.e 0 => 25 it will be animated from 0 to 25.
    • The default is to use 0 => 1 or use the value given by the animation
    defined in the SubAction

Example

myvideo = Video(500, 500)
javis(
    myvideo,
    [
        BackgroundAction(1:100, ground),
        Action(
            (args...; radius = 25) -> object(Point(100, 0), radius, "red"),
            Rotation(0.0, 4π);
            subactions = [
                SubAction(1:50, change(:radius, 25 => 0))
                SubAction(51:100, change(:radius, 0 => 25))
            ],
        )
    ]; pathname = "current/_change.gif"
)
source
Javis.disappearMethod
disappear(s::Symbol)

Disappear can be used inside a SubAction

Example

Action(101:200, (args...)->house_of_nicholas(); subactions = [
    SubAction(1:20, appear(:fade)),
    SubAction(81:100, disappear(:fade))
])

In this case the house_of_nicholas will fade out during the last 20 frames of the Action so 181-200.

Arguments

  • s::Symbol: the symbol defines the animation of disappearance The only symbols that are currently supported are:
    • :fade_line_width which decreases the line width down to 0
    • :fade which decreases the opacity down to 0
    • :scale which decreases the scale down to 0
    • :draw_text which only works for text and let the text disappear from right to left.
source
Javis.draw_gridMethod

draw_grid(video::Video, action::Action, frame::Int; direction::AbstractString = "TR", line_gap = 25)

Draws an oriented grid on the given frame of a Video.

Arguments

  • direction::AbstractString: Where grid animation finishes. Default: "TR" Available Orientations:
    • "TR" - Animation finishes in the Top Right corner of the frame.
    • "TL" - Animation finishes in the Top Left corner of the frame.
    • "BR" - Animation finishes in the Bottom Right corner of the frame.
    • "BL" - Animation finishes in the Bottom Left corner of the frame.
  • line_gap: How many pixels between each line. Default: 25

Example

Example call of this function within an Action.

...
 Action(1:100, :line, draw_grid(direction = "TL", line_gap = 25))
...
source
Javis.follow_pathMethod
follow_path(points::Vector{Point}; closed=true)

Can be applied inside a subaction such that the object defined in the parent action follows a path. It takes a vector of points which can be created as an example by calling circle(O, 50) <- notice that the action is set to :none the default.

Example

SubAction(1:150, follow_path(star(O, 300)))

Arguments

  • points::Vector{Point} - the vector of points the object should follow

Keywords

  • closed::Bool default: true, sets whether the path is a closed path as for example when using a circle, ellipse or any polygon. For a bezier path it should be set to false.
source
Javis.fontsizeMethod
fontsize(fsize)

Same as Luxor.fontsize: Sets the current font size.

Example

fontsize(12)
text("Hello World!")

Arguments:

  • fsize: the new font size
source
Javis.get_angleMethod
get_angle(s::Symbol)

Get access to the angle that got saved in s by a previous action.

Returns

  • Float64: the angle stored by a previous action i.e via return Transformation(p, angle)
source
Javis.get_fontsizeMethod
get_fontsize(fsize)

Same as Luxor.get_fontsize but works with every version of Luxor that is supported by Javis.

Example

fontsize(12)
fsize = get_fontsize()
text("Hello World! $fsize")

Returns

  • Float64: the current font size
source
Javis.get_positionMethod
get_position(s::Symbol)

Get access to the position that got saved in s by a previous action.

Returns

  • Point: the point stored by a previous action.
source
Javis.get_valueMethod
get_value(s::Symbol)

Get access to the value that got saved in s by a previous action. If you want to access a position or angle check out get_position and get_angle.

Returns

  • Any: the value stored by a previous action.
source
Javis.javisMethod
javis(
    video::Video,
    actions::Vector{AbstractAction};
    framerate=30,
    pathname="",
    tempdirectory="",
    liveview=false
)

Similar to animate in Luxor with a slightly different structure. Instead of using actions and a video instead of scenes in a movie.

Arguments

  • video::Video: The video which defines the dimensions of the output
  • actions::Vector{Action}: All actions that are performed

Keywords

  • framerate::Int: The frame rate of the video
  • pathname::String: The path for the rendered gif or mp4 (i.e output.gif or output.mp4)
  • tempdirectory::String: The folder where each frame is stored Defaults to a temporary directory when not set
  • liveview::Bool: Causes a live image viewer to appear to assist with animation development

Example

function ground(args...)
    background("white")
    sethue("black")
end

function circ(p=O, color="black")
    sethue(color)
    circle(p, 25, :fill)
    return Transformation(p, 0.0)
end

from = Point(-200, -200)
to = Point(-20, -130)
p1 = Point(0,-100)
p2 = Point(0,-50)
from_rot = 0.0
to_rot = 2π

demo = Video(500, 500)
javis(demo, [
    Action(1:100, ground),
    Action(1:100, :red_ball, (args...)->circ(p1, "red"), Rotation(from_rot, to_rot)),
    Action(1:100, (args...)->circ(p2, "blue"), Rotation(to_rot, from_rot, :red_ball))
], tempdirectory="images", pathname="rotating.gif")

This structure makes it possible to refer to positions of previous actions i.e :red_ball is an id for the position or the red ball which can be used in the rotation of the next ball.

source
Javis.latexMethod
latex(text::LaTeXString, pos::Point, action::Symbol)

Add the latex string text to the top left corner of the LaTeX path. Can be added to Luxor.jl graphics via Video.

NOTES:

  • This only works if tex2svg is installed. It can be installed using the following command (you may have to prefix this command with sudo depending on your installation):

      npm install -g mathjax-node-cli
  • The latex method must be called from within an Action.

Arguments

  • text::LaTeXString: a LaTeX string to render.
  • pos::Point: position of the upper left corner of the latex text. Default: O
    • can be written as x, y instead of Point(x, y)
  • action::Symbol: graphics actions defined by Luxor.jl. Default :stroke.

Available actions:

  • :stroke - Draws the latex string on the canvas. For more info check Luxor.strokepath
  • :path - Creates the path of the latex string but does not render it to the canvas.

Throws

  • IOError: mathjax-node-cli is not installed

Example

using Javis
using LaTeXStrings

function ground(args...)
    background("white")
    sethue("black")
end

function draw_latex(video, action, frame)
    fontsize(50)
    x = 100
    y = 120
    latex(L"\sqrt{5}", x, y)
end

demo = Video(500, 500)
javis(demo, [BackgroundAction(1:2, ground), Action(draw_latex)],
      pathname = "latex.gif")
source
Javis.morphMethod
morph(from_func::Function, to_func::Function; action=:stroke)

A closure for the _morph function. This makes it easier to write the function inside an Action.

Currently morphing is quite simple and only works for basic shapes. It especially does not work with functions which produce more than one polygon or which produce filled polygons. Blending between fills of polygons is definitely coming at a later stage.

Important: The functions itself should not draw the polygon i.e. use circle(Point(100,100), 50) instead of circle(Point(100,100), 50, :stroke)

Arguments

  • from_func::Function: The function that creates the path for the first polygon.
  • to_func::Function: Same as from_func but it defines the "result" polygon, which will be displayed at the end of the Action

Keywords

  • action::Symbol defines whether the object has a fill or just a stroke. Defaults to stroke.

Example

This creates a star that morphs into a circle and back.

using Javis

astar(args...) = star(O, 50)
acirc(args...) = circle(Point(100,100), 50)

video = Video(500, 500)
javis(video, [
    Action(1:100, ground),
    Action(1:50, morph(astar, acirc)),
    Action(51:100, morph(acirc, astar))
], creategif=true, tempdirectory="images",
    pathname="star2circle.gif", deletetemp=true)
source
Javis.revMethod
rev(e::Easing)

Reverse an easing function such that easing_to_animation maps it to [1.0, 0.0] instead of [0.0, 1.0]. An example can be seen in rotate

source
Javis.rotate_aroundMethod
rotate_around(p::Point)

Rotate a function defined inside a SubAction using an Animation defined with Animations.jl around the point p.

An example can be seen in rotate.

Arguments

  • p::Point: the point to rotate around
source
Javis.scaleMethod
scale(scl_x, scl_y)

Same as scale but the x scale and y scale can be changed independently.

Arguments:

  • scl_x: scale in x direction
  • scl_y: scale in y direction
source
Javis.scaleMethod
scale(scl)

Set the scale and multiply it with the current multiplier which is i.e. set by appear and disappear.

Normal behavior without any animation is the same as Luxor.scale.

Example

scale(0.5)
circle(O, 20, :fill) # the radius would be 10 because of the scaling

Arguments:

  • scl: the new default scale
source
Javis.scaleMethod
scale()

Scale a function defined inside a SubAction using an Animation defined with Animations.jl around the point p.

An example can be seen in rotate.

source
Javis.scaletoMethod
scaleto(x, y)

Scale to a specific scaling instead of multiplying it with the current scale. For scaling on top of the current scale have a look at scale.

source
Javis.setlineMethod
setline(linewidth)

Set the line width and multiply it with the current multiplier which is i.e. set by appear and disappear.

Normal behavior without any animation is the same as Luxor.setline.

Example

setline(10)
line(O, Point(10, 10))

Arguments:

  • linewidth: the line width in pixel
source
Javis.setopacityMethod
setopacity(opacity)

Set the opacity and multiply it with the current multiplier which is i.e. set by appear and disappear.

Normal behavior without any animation is the same as Luxor.setopacity.

Example

setopacity(0.5)
circle(O, 20, :fill)

Arguments:

  • opacity: the opacity between 0.0 and 1.0
source
Javis.textFunction
text(str, pos = O; valign = :baseline, halign = :left, angle = 0.0)

Has bacially the same functionality as Luxor.text but overrides that method to allow to animate text with appear.

Example

Action(
    1:100,
    (args...) -> text("Hello Stream!"; halign = :center);
    subactions = [
        SubAction(1:15, sineio(), appear(:draw_text)),
        SubAction(76:100, sineio(), disappear(:draw_text)),
    ],
)

draws the text from left to right in the first 15 frames and in the last 15 frames it disappears.

Arguments

  • str::AbstractString the string that should be shown
  • pos::Point defaults to the origin and can be written as x,y as well as Point(x,y).

Keywords

  • valign::Symbol defaults to :baseline and takes (:top, :middle, :bottom, :baseline)
  • halign::Symbol defaults to :left and takes (:left, :center, :centre, :right)
  • angle::Float64 defaults to 0.0 and specifies the angle of the text
source
Javis.zero_linesMethod

zero_lines(video::Video, action::Action, frame::Int; direction::AbstractString = "TR", line_thickness = 10)

Draws zero lines on the given frame of a Video.

Arguments

  • direction::AbstractString: Direction for how vertical and horizontal axes are drawn.

Default: "TR" Available Orientations:

  • "TR" - Vertical axis drawn towards the Top and horizontal axis drawn to the Right of the frame.
  • "TL" - Vertical axis drawn towards the Top and horizontal axis drawn to the Left of the frame.
  • "BR" - Vertical axis drawn towards the Bottom and horizontal axis drawn to the Right of the frame.
  • "BL" - Vertical axis drawn towards the Bottom and horizontal axis drawn to the Left of the frame.
  • line_thickness: Defines the thickness of the zero lines. Default: 10

Example

This example will produce an animation with the vertical axis being drawn towards the top and the horizontal axis being drawn towards the left. One will need to define their own path for tempdirectory and pathname.

...
 Action(1:100, :line, zero_lines(direction = "TL", line_thickness = 10)),
...
source
Luxor.rotateMethod
rotate()

Rotate a function defined inside a SubAction using an Animation defined with Animations.jl.

If you're used to working with Animations.jl this should feel quite natural. Instead of defining each movement in its own subaction it's possible to define it in one by using an Animation.

Example

using Javis, Animations

video = Video(500, 500)
translate_anim = Animation(
    [0, 1], # must go from 0 to 1
    [O, Point(150, 0)],
    [sineio()],
)

translate_back_anim = Animation(
    [0, 1], # must go from 0 to 1
    [O, Point(-150, 0)],
    [sineio()],
)

rotate_anim = Animation(
    [0, 1], # must go from 0 to 1
    [0, 2π],
    [linear()],
)

javis(
    video,
    [
        BackgroundAction(1:150, ground),
        Action(
            (args...) -> circle(O, 25, :fill);
            subactions = [
                SubAction(1:10, sineio(), scale()),
                SubAction(11:50, translate_anim, translate()),
                SubAction(51:100, rotate_anim, rotate_around(Point(-150, 0))),
                SubAction(101:140, translate_back_anim, translate()),
                SubAction(141:150, rev(sineio()), scale())
            ],
        ),
    ],
    pathname = "animation.gif",
)

which uses the SubAction syntax five times with both easing functions directly and animation objects. The rev(sineio()) creates an Animation which goes from 1.0 to 0.0.

source
Luxor.sethueMethod
sethue()

Set the color of a function defined inside a SubAction using an Animation defined with Animations.jl.

Example

A possible animation would look like this:

color_anim = Animation(
    [0, 0.5, 1], # must go from 0 to 1
    [
        Lab(colorant"red"),
        Lab(colorant"cyan"),
        Lab(colorant"black"),
    ],
    [sineio(), sineio()],
)

An example on how to integrate this into a SubAction can be seen in rotate. Where this would be a valid SubAction: SubAction(1:150, color_anim, sethue()).

source
Luxor.translateMethod
translate()

Translate a function defined inside a SubAction using an Animation defined with Animations.jl.

If you're used to working with Animations.jl this should feel quite natural. Instead of defining each movement in its own subaction it's possible to define it in one by using an Animation.

Example

using Javis, Animations

function ground(args...)
    background("black")
    sethue("white")
end

video = Video(500, 500)
circle_anim = Animation(
    [0.0, 0.3, 0.6, 1.0], # must go from 0 to 1
    # the circle will move from the origin to `Point(150, 0)` then `Point(150, 150)`
    # and back to the origin `O`.
    [O, Point(150, 0), Point(150, 150), O],
    [sineio(), polyin(5), expin(8)],
)
javis(
    video, [
        BackgroundAction(1:150, ground),
        Action((args...)->circle(O, 25, :fill); subactions=[
            SubAction(1:150, circle_anim, translate())
        ])
    ], pathname="moving_a_circle.gif"
)

This notation uses the Animations.jl library very explicitly. It's also possible to do the same with:

javis(
    video,
    [
        BackgroundAction(1:150, ground),
        Action((args...)->circle(O, 25, :fill); subactions = [
            SubAction(1:50, sineio(), Translation(150, 0)),
            SubAction(51:100, polyin(2), Translation(0, 150)),
            SubAction(101:150, expin(8), Translation(-150, -150))
        ])
    ],
    pathname = "moving_a_circle_javis.gif",
)

which uses the SubAction syntax three times and only uses easing functions instead of specifying the Animation directly.

Here circle_anim defines the movement of the circle. The most important part is that the time in animations has to be from 0.0 to 1.0.

source

Private functions

Javis.CURRENT_ACTIONConstant
CURRENT_ACTION

holds the current action in an array to be declared as a constant The current action can be accessed using CURRENT_ACTION[1]

source
Javis.CURRENT_VIDEOConstant
CURRENT_VIDEO

holds the current video in an array to be declared as a constant The current video can be accessed using CURRENT_VIDEO[1]

source
Javis.ActionSettingType
ActionSetting

The current settings of an Action which are saved in action.current_setting.

Fields

  • line_width::Float64: the current line width
  • mul_line_width::Float64: the current multiplier for line width. The actual line width is then: mul_line_width * line_width
  • opacity::Float64: the current opacity
  • mul_opacity::Float64: the current multiplier for opacity. The actual opacity is then: mul_opacity * opacity
  • fontsize::Float64 the current font size
  • show_action::Bool is set to false if scale would be 0.0 which is forbidden by Cairo
  • current_scale::Tuple{Float64, Float64}: the current scale
  • desired_scale::Tuple{Float64, Float64}: the new desired scale
  • mul_scale::Float64: the multiplier for the new desired scale. The actual new scale is then: mul_scale * desired_scale
source
Javis.FramesType
Frames

Stores the actual computed frames and the user input which can be :same or Rel(10). The frames are computed in javis.

source
Javis._decrementMethod
_decrement(video::Video, widgets::Vector, actions::Vector, dims::Vector,
    canvas::Gtk.Canvas, frames::Int)

Decrements a given value and returns the associated frame.

source
Javis._draw_imageMethod
_draw_image(video::Video, actions::Vector, frame::Int, canvas::Gtk.Canvas,
img_dims::Vector)

Internal function to create an image that is drawn on a Gtk Canvas.

source
Javis._incrementMethod
_increment(video::Video, widgets::Vector, actions::Vector, dims::Vector,
    canvas::Gtk.Canvas, frames::Int)

Increments a given value and returns the associated frame.

source
Javis._javis_viewerFunction
 _javis_viewer(video::Video, frames::Int, action_list::Vector, show::Bool)

Internal Javis Viewer built on Gtk that is called for live previewing.

source
Javis._morphMethod
_morph(video::Video, action::Action, frame, from_func::Function, to_func::Function; draw_action=:stroke)

Internal version of morph but described there.

source
Javis.animate_textMethod
animate_text(
    str,
    pos::Point,
    valign::Symbol,
    halign::Symbol,
    angle::Float64,
    t::Float64,
)

This function is used as a subfunction of text and animates the str by clipping the textoutlines and creating a growing circle in the lower left corner to display the text from left to right in an animated fashion.

source
Javis.compute_frames!Method
compute_frames!(actions::Vector{AA}; last_frames=nothing) where AA <: AbstractAction

Set action.frames.frames to the computed frames for each action in actions.

source
Javis.compute_transition!Method
compute_transition!(action::AbstractAction, video::Video, frame::Int)

Update action.internal_transitions for the current frame number

source
Javis.compute_transition!Method
compute_transition!(internal_rotation::InternalRotation, rotation::Rotation, video,
                    action::AbstractAction, frame)

Computes the rotation transformation for the action. If the Rotation is given directly it uses the frame number for interpolation. If rotation includes symbols the current definition of that look up is used for computation.

source
Javis.compute_transition!Method
compute_transition!(internal_translation::InternalScaling, translation::Scaling,
                    video, action::AbstractAction, frame)

Computes the scaling transformation for the action. If the scaling is given directly it uses the frame number for interpolation. If scaling includes symbols, the current definition of that symbol is looked up and used for computation.

source
Javis.compute_transition!Method
compute_transition!(internal_translation::InternalTranslation, translation::Translation,
                    video, action::AbstractAction, frame)

Computes the translation transformation for the action. If the translation is given directly it uses the frame number for interpolation. If translation includes symbols the current definition of that symbol is looked up and used for computation.

source
Javis.create_internal_transitions!Method
create_internal_transitions!(action::AbstractAction)

For every translation an internal translation is added to action.internal_transitions. Same is true for all other transitions.

source
Javis.draw_objMethod
draw_obj(::Val{:g}, o, defs)

Draws a group by setting the attributes (like transformations) and then calls draw_obj for all child elements.

source
Javis.draw_objMethod
draw_obj(::Val{:path}, o, defs)

Calls the commands specified in the path data. Currently supports only a subset of possible SVG commands.

source
Javis.draw_objMethod
draw_obj(::Val{:rect}, o, defs)

Draw the rectangle defined by the object o.

source
Javis.easing_to_animationMethod
easing_to_animation(easing)

Converts an easing to an Animation with time goes from 0.0 to 1.0 and value from 0 to 1.

source
Javis.easing_to_animationMethod
easing_to_animation(rev_easing::ReversedEasing)

Converts an easing to an Animation with time goes from 0.0 to 1.0 and value from 1 to 0.

source
Javis.get_framesMethod
get_frames(a::AbstractAction)

Return a.frames.frames which holds the computed frames for the AbstractAction a.

source
Javis.get_framesMethod
get_frames(frames::Rel, last_frames::UnitRange)

Return the frames based on a relative frames Rel object and the last_frames.

source
Javis.get_framesMethod
get_frames(frames::Symbol, last_frames::UnitRange)

Get the frames based on a symbol (currently only same) and the last_frames. Throw ArgumentError if symbol is unknown

source
Javis.get_interpolationMethod
get_interpolation(action::AbstractAction, frame)

Return the value of the action.anim Animation based on the relative frame given by get_interpolation(get_frames(action), frame)

source
Javis.get_interpolationMethod
get_interpolation(frames::UnitRange, frame)

Return a value between 0 and 1 which represents the relative frame inside frames.

source
Javis.get_javis_frameMethod
get_javis_frame(video, actions, frame)

Get a frame from an animation given a video object, its actions, and frame.

Arguments

  • video::Video: The video which defines the dimensions of the output
  • actions::Vector{Action}: All actions that are performed
  • frame::Int: Specific frame to be returned

Returns

  • Array{ARGB32, 2} - request frame as a matrix
source
Javis.get_scaleMethod
get_scale(s::Symbol)

Get access to the scaling that got saved in s by a previous action.

Returns

  • Scaling: the scale stored by a previous action.
source
Javis.match_num_point!Method
match_num_point!(poly_1::Vector{Point}, poly_2::Vector{Point})

This is a helper function for morph. Given two polygons poly_1 and poly_2 points are added to the polygon with less points until both polygons have the same number of points. The polygon with less points gets mutated during this process.

Arguments

  • poly_1::Vector{Point}: The points which define the first polygon
  • poly_2::Vector{Point}: The points which define the second polygon
source
Javis.path_quadraticMethod
path_quadratic(c_pt::Point, x,y, xe, ye)

Drawing a quadratic bezier curve by computing a cubic one as that is supported by Luxor

source
Javis.pathsvgMethod
pathsvg(svg)

Convert an svg to a path using Luxor. Normally called via the latex command. It handles only a subset of the full power of svg.

source
Javis.perform_actionMethod
perform_action(action, video, frame, origin_matrix)

Is called inside the javis and does everything handled for an AbstractAction. It is a 4-step process:

  • compute the transformation for this action (translation, rotation, scale)
  • do the transformation
  • call the action function
  • save the result of the action if wanted inside video.defs
source
Javis.save_morph_polygons!Method
save_morph_polygons!(action::Action, from_func::Function, to_func::Function)

Converts the paths created by the functions to polygons and calls match_num_point! such that both polygons have the same number of points. This is done once inside _morph. Saves the two polygons inside action.opts[:from_poly] and action.opts[:to_poly].

Assumption: Both functions create only a single polygon each.

source
Javis.set_action_defaults!Method
set_action_defaults!(action)

Set the default action values

  • line_width and calls Luxor.setline.
  • opacity and calls Luxor.opacity.
  • scale and calls Luxor.scale.
source
Javis.set_attrMethod
set_attr(::Val{:transform}, transform_str)

Call the corresponding set_transform method i.e matrix, scale and translate

source
Javis.set_attrsMethod
set_attrs(o)

Setting the attributes of the object o by calling set_attr methods.

source
Javis.set_frames!Method
set_frames!(a::AbstractAction, last_frames::UnitRange)

Compute the frames based on a.frames and last_frames. Save the result in a.frames.frames which can be accessed via get_frames.

source
Javis.set_transformMethod
set_transform(::Val{:matrix}, args...)

Multiply the new matrix with the current matrix and set it.

source
Javis.update_ActionSetting!Method
update_ActionSetting!(as::ActionSetting, by::ActionSetting)

Set the fields of as to the same as by. Basically copying them over.

source