Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Animations.jl #125

Merged
merged 18 commits into from
Sep 7, 2020
Merged

Using Animations.jl #125

merged 18 commits into from
Sep 7, 2020

Conversation

Wikunia
Copy link
Member

@Wikunia Wikunia commented Aug 27, 2020

PR Checklist

If you are contributing to Javis.jl, please make sure you are able to check off each item on this list:

  • Did I update CHANGELOG.md with whatever changes/features I added with this PR?
  • Did I update the TODO.md (if applicable)?
  • Did I make sure to only change the part of the file where I introduced a new change/feature?
  • Did I cover all corner cases to be close to 100% test coverage (if applicable)?
    • Needs one for error checking
  • Did I properly add test dependencies to the test directory (if applicable)?
    • Added Animations.jl
  • Did I check relevant tutorials that may be affected by changes in this PR?
  • Did I clearly articulate why this PR was made the way it was and how it was made?

Link to relevant issue(s)
Closes #42

How did you address these issues with this PR? What methods did you use?
Currently the following syntax is used to define the easing function for interpolation:

  • Use linear as default which makes this non-breaking
video = Video(1000, 700)
javis(
    video, [
        BackgroundAction(1:150, ground),
        Action((args...)->circle(Point(-300, -300), 25, :fill); subactions=[
            SubAction(1:50, sineio(), Translation(500, 0))
            SubAction(51:100, polyin(2), Translation(0, 500))
            SubAction(101:150, expin(8), Translation(-500, -500))
        ])
    ], pathname="current/sine_trans.gif"
)

with the result: sine_trans

or similarly:

javis(
    video, [
        BackgroundAction(1:150, ground),
        Action((args...)->circle(Point(-300, -300), 25, :fill), sineio(), Translation(500, 0))
    ], pathname="current/sine_trans.gif"
)

if one doesn't work with subactions.

The appear, disappear and transformation functions now access the interpolation value t via get_interpolation(action, frame).

This does currently not contain tests but contains a bugfix which is also available in #121 which defines the linear interpolation in appear and disappear which was wrong before.

I would like to be able to write something like:

circle_anim = Animation(
    [0, 0.3, 0.6, 1], # must go from 0 to 1
    [O, Point(500, 0), Point(500, 500), O],
    [sineio(), polyin(5), expin(8)],
)
javis(
    video, [
        BackgroundAction(1:150, ground),
        Action((args...)->circle(Point(-300, -300), 25, :fill); subactions=[
            SubAction(1:150, circle_anim, translate())
        ])
    ], pathname="current/sine_trans.gif"
)

this will be done in the next step. Anything against this syntax? @TheCedarPrince

Additional Info about v0.2
This PR introduces Animations.jl therefore merging is done into v0.2 and not master.

@Wikunia Wikunia added enhancement New feature or request question Further information is requested labels Aug 27, 2020
@codecov
Copy link

codecov bot commented Aug 27, 2020

Codecov Report

Merging #125 into v0.2 will increase coverage by 0.47%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             v0.2     #125      +/-   ##
==========================================
+ Coverage   97.44%   97.91%   +0.47%     
==========================================
  Files           7        7              
  Lines         508      719     +211     
==========================================
+ Hits          495      704     +209     
- Misses         13       15       +2     
Impacted Files Coverage Δ
src/Javis.jl 97.46% <100.00%> (+1.15%) ⬆️
src/luxor_overrides.jl 100.00% <100.00%> (ø)
src/subaction_animations.jl 100.00% <100.00%> (ø)
src/util.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b5fc3dd...7ebc34f. Read the comment docs.

@Wikunia Wikunia linked an issue Aug 27, 2020 that may be closed by this pull request
@Wikunia Wikunia requested a review from TheCedarPrince August 27, 2020 15:46
@Wikunia
Copy link
Member Author

Wikunia commented Aug 28, 2020

The last commit makes the following reality:

A section from the docs:

translate()

Translate a function defined inside an Action 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"
)

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.

Copy link
Member

@TheCedarPrince TheCedarPrince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like how you handled this. I was originally somewhat confused by what this is all doing, but now I understand what Animations.jl is exactly doing. Really like the way you can preserve Animations.jl syntax while also providing Javis.jl syntax. I feel like it offers a lot of flexibility to the user. Cool stuff man!

src/Javis.jl Outdated Show resolved Hide resolved
src/Javis.jl Show resolved Hide resolved
src/Javis.jl Show resolved Hide resolved
src/subaction_animations.jl Show resolved Hide resolved
src/subaction_animations.jl Show resolved Hide resolved
src/util.jl Outdated Show resolved Hide resolved
@Wikunia
Copy link
Member Author

Wikunia commented Aug 30, 2020

If you think the translate function makes sense I would add the same for scale and rotate.

@TheCedarPrince
Copy link
Member

I think the translate function makes sense so feel free to add the other two @Wikunia! Otherwise, I just finished doing a review this and you have my approval to merge when ready.

@Wikunia Wikunia removed the question Further information is requested label Aug 31, 2020
@Wikunia Wikunia mentioned this pull request Aug 31, 2020
@Wikunia
Copy link
Member Author

Wikunia commented Sep 1, 2020

animations

Can be done with:

using Javis, Animations

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



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 = "current/animations.gif",
)

@TheCedarPrince TheCedarPrince self-requested a review September 1, 2020 17:09
@Wikunia
Copy link
Member Author

Wikunia commented Sep 1, 2020

Oh I think I should add some more coverage before merging and it would be nice to also have
this functionality for sethue to interpolate colors. @experimentMartin wants to see more weird colors on my stream.

Copy link
Member

@TheCedarPrince TheCedarPrince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one typo but also check out luxor_overrides and subaction_animations. Code coverage picked up that there are some lines not being covered in our tests there. :P

src/subaction_animations.jl Outdated Show resolved Hide resolved
@Wikunia
Copy link
Member Author

Wikunia commented Sep 4, 2020

animations

This is what we can create now with sethue.

@Wikunia Wikunia changed the title [WIP] Using Animations.jl Using Animations.jl Sep 4, 2020
Copy link
Member

@TheCedarPrince TheCedarPrince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything works on my end as expected. Feel free to merge when ready!

@Wikunia Wikunia merged commit ed48738 into v0.2 Sep 7, 2020
@Wikunia Wikunia deleted the wik-feature-42 branch September 7, 2020 17:03
@Wikunia Wikunia restored the wik-feature-42 branch September 8, 2020 14:18
TheCedarPrince added a commit that referenced this pull request Sep 25, 2020
* Wik feature progressmeter (#137)

* Merged the latest master into v0.2
* Using ProgressMeter

* VideoIO to render mp4 without saving temp frames (#138)

* first version of VideoIO with mp4

* fixing links in documentation (#144) (#145)

* fixing links in documentation (#144)

* first version of HowTo (#142)

* Using Animations.jl (#125)

* first version of Animations.jl

* don't allow v2.5 of Luxor because of transposing (#149)

* Wik documentation howto (#148)

* made review changes for HowTo

* docstrings for structs (#150)

* Forgot to push sethue to Animations.jl (#153)

* allow sethue in Animations.jl
* allow 2.5.1 of Luxor
* added extra line for an example of `sethue`

* merge master in v0.2

* Format file for the repository

* Removing old contributing file

* Added info on dependencies and JuliaFormatter

* Revert "merge master in v0.2"

This reverts commit a853a0f.

* Revert files to a853a0f

* Tutorial animations (#157)

* Animation tutorial

* Wik feature morphing v2 (#154)

* ability to morph with fill.

* [WIP] Live Preview (#119)

* Starting proof of concept on live preview

* Reverted Javis.jl to previous formatting

* Began work on proof of concept

* Beginning of the javis image viewer

* Continued work on trying to preview images

* Barebones example of GTK image viewer

* get_javis_frame function

* Added compat for images and updated authors

* Proof of concept javis viewer signal emission

* Temporary fix for Image compat

* Added buttons and todos

* Added functionality for buttons

* Fixed up Project TOML for compat with Images

* Fixed merge conflict logic bug

* Got proof of concept of live viewer working

* Beginning clean up of javis image viewer

* Added ColorTypes and color conversion for frames

* Added ColorTypes dependency

* Cleaned up and adding documentation strings

* Exported get_javis_frame function

* Prepped javis viewer for full integration into Javis

* Added Gtk and GtkReactive deps

* Added liveview kwarg

* Finished prototype of javis viewer

* Updated boundaries for deps

* Clarified docstrings

* Added arrow key navigation through frames

* Updated boundaries per Ole suggestion

* Fixed up formatting for CI

* Made live rendering faster

* Added loop around functionality

* Adjusted boundaries of deps

* Increased speed of image preview display

* Functionalized repeated code snippets

* Bug in javis viewer - identification attempt

* Made javis viewer work completely

* Reversion to a6fa540

* Made short circuit eval of live viewer

* Documented javis viewer thoroughly

* Added docstring

* Qualified usage of LightXML.value func

* Qualified textbox usage

* Formatting... 👀

* test with xvfb on ubuntu

* without --project

* try with project=.

* different idea using DISPLAY

* fix Documentation CI

* Added documentation for get_javis_frame

* Reduced code reuse

* Added some clarifications

* Removed export of get_javis_frame

* Changed returns for testing

* Added GtkReactive to Project

* Tests for javis_viewer

* Formatting again

* Final test case for increment/decrement tests

* Formatting test file

* Final clean up to javis viewer

Co-authored-by: Ole Kröger <[email protected]>

* removed possibility to set the fontsize inside the latex function (#180)

* removed possibility to set the fontsize inside the latex function

* ability to animate text (#162)

* ability to animate text

* Let us follow a path (#163)

* Let us follow a path

* push preview (#182)

* Update Change Log (#183)

* Added info about live viewer and javis frame

* Added info about drawing text

* Improved Action Error Msg (#185)

* Added error msg about defining Video first

* Added unit test and cleaned up code

* How To:  draw_text, follow_path and liveview (#184)

* added draw_text, follow_path and liveview in HowTo

* return 1.0 in interpolation for single frame (#188)

* [Bugfix] scaling to 0 (#191)

* don't ever scale to 0 :D

* [Bugfix] Follow path starting after first frame (#192)

* bugfix for follow_path if not on first frame

* Drafted showcase table for README

* Images for drafted showcase

* Formatted tables for showcase

* Wik examples follow path (#198)

* first version of an examples folder: drawing a car

* convert frame only once (#199)

* no need to convert to ARGB32

* refactoring (#194)

* refactoring

* merge fix renaming

* resolved typos

* Added back headers for table

* Update for Tutorial 5 (#200)

* Remove any files stored in test/images (#195)

* Remove any files stored in test/images

* Removed file check and created it as a unit test

* Unit test for test/images dir to check for additional files

* Added formatting

* Began update of tutorial 5

* Updated gifs

* Fixed gifs

* Added additional explanation on SubAction

* Merged unit with v0.2

* Added example of drawing a path

* Resized gif to 350 x 350

* fixed tutorial links in readme

* Changed compat entries to allow more (#202)

* changed compat entries to allow more

* changelog ready for merge

* Tutorial overhaul (#201)

* explaining Action and Scaling and fixing some others

* removed some "The"

* emoji fixes and some other small things

* Corrected grammar and some light editing

* Fixed some grammar issues

Co-authored-by: Jacob Zelko <[email protected]>

* Added Examples Page (#203)

* Added examples page link

* Added bezier path gif

* Drafted first table for examples

* Rendered examples properly

* Added explanation for example

* Fixed reference

Co-authored-by: Jacob Zelko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using Animations.jl
2 participants