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

fix follow_path for objects with start_pos #496

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- tutorial on partial draw / show creation
- Few tests for morphs added
- test for partial draw/ show creation
- fix for `follow_path` for objects with `start_pos` other than O

## v0.9.0 (26th of May 2022)
- Ability to use Luxor functionality without rendering an animation
Expand Down
10 changes: 5 additions & 5 deletions src/action_animations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -416,26 +416,26 @@ function _follow_path(video, object, action, rel_frame, points; closed = closed)
# if t is discrete and not 0.0 take the last point or first if closed
if !isfirstframe && isapprox_discrete(t)
if closed
translate(points[1])
translate(points[1] - object.start_pos)
else
translate(points[end])
translate(points[end] - object.start_pos)
end
return
end
# get only the frobjectal part to be between 0 and 1
t -= floor(t)
if isfirstframe
# compute the distances only once for performance reasons
action.defs[:p_dist] = polydistances(points, closed = closed)
action.defs[:p_dist] = polydistances(points .- object.start_pos, closed = closed)
end
if isapprox(t, 0.0, atol = 1e-4)
translate(points[1])
translate(points[1] - object.start_pos)
return
end
pdist = action.defs[:p_dist]

overshootpoint = get_polypoint_at(points, t; pdist = pdist)
translate(overshootpoint)
translate(overshootpoint - object.start_pos)
end

"""
Expand Down