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

[GSoC'21] Different morphing modes #374

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Javis.jl - Changelog

## Unreleased
- Add a manim-like :long morhping mode
Copy link
Member

Choose a reason for hiding this comment

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

Should be updated here as well


## v0.6.1 (7th of August 2021)
- Add shorthands for basic shapes
- New functions `JBox, JCircle, JEllipse, JLine, JPoly, JRect, JStar, @JShape`
Expand Down
2 changes: 1 addition & 1 deletion src/Shape.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function prepare_to_interpolate(from_shape, to_shape, style)
rotate_i, _ = compute_shortest_morphing_dist(from_outer, to_outer)
new_from_outer = circshift(from_outer, -rotate_i + 1)

if style == :long
if style == :mode1
new_from_outer =
circshift(reverse!(new_from_outer), floor(Int, -length(new_from_outer) / 2.6)) # found this to work best
end
Expand Down
12 changes: 6 additions & 6 deletions src/morphs.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include("Shape.jl")

"""
morph_to(to_func::Function; style=:short, object=:stroke)
morph_to(to_func::Function; style=:default, object=:stroke)

A closure for the [`_morph_to`](@ref) function.
This makes it easier to write the function inside an `Object`.
Expand Down Expand Up @@ -39,7 +39,7 @@ circle_obj = Object(11:20, acirc)
act!(circle_obj, Action(:same, morph_to(astar)))
```
"""
function morph_to(to_func::Function; style = :short, do_action = :stroke)
function morph_to(to_func::Function; style = :default, do_action = :stroke)
return (video, object, action, frame) -> _morph_to(
video,
object,
Expand All @@ -53,7 +53,7 @@ end


"""
_morph_to(video::Video, object::Object, action::Action, frame, to_func::Function; style=:short, do_action=:stroke)
_morph_to(video::Video, object::Object, action::Action, frame, to_func::Function; style=:default, do_action=:stroke)

Internal version of [`morph_to`](@ref) but described there.
"""
Expand All @@ -63,7 +63,7 @@ function _morph_to(
action::Action,
frame,
to_func::Function;
style = :short,
style = :default,
do_action = :stroke,
)
if frame == last(get_frames(action))
Expand Down Expand Up @@ -98,7 +98,7 @@ end
"""
morph_between(video::Video, action::Action, frame,
from_polys::Vector{Vector{Point}}, to_polys::Vector{Vector{Point}};
style=:short, do_action=:stroke)
style=:default, do_action=:stroke)

Internal version of [`morph_to`](@ref) after the from poly is defined.
"""
Expand All @@ -108,7 +108,7 @@ function morph_between(
frame,
from_polys::Vector{Vector{Point}},
to_polys::Vector{Vector{Point}};
style = :short,
style = :default,
do_action = :stroke,
)
cs = get_current_setting()
Expand Down
4 changes: 2 additions & 2 deletions test/morphing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ end
back = Background(1:50, ground)
star_obj = Object(1:50, astar)
box_obj = Object(1:50, abox)
act!(star_obj, Action(5:20, morph_to(acirc, style = :long)))
act!(box_obj, Action(30:50, morph_to(astar, style = :long)))
act!(star_obj, Action(5:20, morph_to(acirc, style = :mode1)))
act!(box_obj, Action(30:50, morph_to(astar, style = :mode1)))
render(video; tempdirectory = "images", pathname = "")

for i in [5, 10, 15, 19, 20, 21, 30, 35, 40, 45, 49, 50]
Expand Down