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

first attempt at DelayedPosition #434

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
01a4819
first attempt at DelayedPosition
gpucce Oct 20, 2021
64c46ac
reset STARTED_RENDERING at the end of render
gpucce Oct 20, 2021
908819b
Merge branch 'master' into add_delayedposition
gpucce Oct 26, 2021
7d2ab4e
add types to DelayedPosition and add DelayedPosition to Rotation
gpucce Oct 26, 2021
c53da96
add first test for delayed
gpucce Oct 28, 2021
5e5d08b
format
gpucce Oct 28, 2021
dc47929
fix testset name
gpucce Oct 28, 2021
44807f6
add .keep back
gpucce Oct 28, 2021
473add2
fix test in util not cleaning images folder
gpucce Oct 28, 2021
073a575
adjust testing so .keep does not get removed
gpucce Oct 28, 2021
0003112
format
gpucce Oct 28, 2021
a5550c0
Merge remote-tracking branch 'upstream/master' into add_delayedposition
gpucce Oct 31, 2021
64f6f29
add test for rotation and initial support for layers
gpucce Oct 31, 2021
f2ce80d
add +,- for betwenn delayedposition and poin
gpucce Nov 4, 2021
3944a90
format tests
gpucce Nov 4, 2021
8e1c204
minor operation change
gpucce Nov 4, 2021
a9d3837
add test for +
gpucce Nov 4, 2021
dd3e312
add test for delayedposition +/- point both left and right
gpucce Nov 4, 2021
c9ff494
change from STARTED_RENDERING to CURRENTLY_RENDERING and add test for it
gpucce Nov 4, 2021
53a8107
adjust to master
gpucce Nov 6, 2021
bb316f3
add minimal doc for DelayedPosition
gpucce Nov 6, 2021
8499128
adjust tests
gpucce Nov 7, 2021
4fe938f
doc change
gpucce Nov 7, 2021
5dcf4a2
reset tests
gpucce Nov 8, 2021
cad53fe
Merge remote-tracking branch 'upstream/master' into add_delayedposition
gpucce Dec 4, 2021
974dcf0
Merge remote-tracking branch 'upstream/master' into add_delayedposition
gpucce Feb 18, 2022
4d71361
add support for delayed_position in all shorthands except @JShape
gpucce Feb 22, 2022
20e6f40
improve howto
gpucce Feb 22, 2022
4cb3182
Merge branch 'master' of https://github.com/JuliaAnimators/Javis.jl i…
gpucce Feb 22, 2022
4e9c677
fix test
gpucce Feb 22, 2022
16b65d0
add delayed_pos for layers
gpucce Feb 24, 2022
507fbae
fix JEllipse and add more tests
gpucce Feb 24, 2022
b7a205b
Change from PointOrDelayed to Luxor.AbstractPoint
gpucce Feb 24, 2022
f1fb9e2
format
gpucce Feb 24, 2022
e0b6cb7
Minor changes
gpucce Feb 25, 2022
a309fb2
reenable some unit tests
gpucce Feb 26, 2022
dfe7d49
format
gpucce Feb 26, 2022
dce3bda
export get_delayed_position
gpucce Mar 2, 2022
9a24a21
fix types
gpucce Mar 2, 2022
a20bd27
add docs to centered_point
gpucce Mar 2, 2022
0b702a1
fix example in howto.md
gpucce Mar 2, 2022
5be8a05
Merge remote-tracking branch 'upstream/main' into add_delayedposition
gpucce Mar 2, 2022
207f03b
update changelog
gpucce Mar 9, 2022
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
8 changes: 8 additions & 0 deletions src/Javis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Transformation(p, a) = Transformation(p, a, 1.0)
Transformation(p, a, s::Float64) = Transformation(p, a, (s, s))
Transformation(p, a, s::Tuple{Float64,Float64}) = Transformation(p, a, Scale(s...))

include("structs/Delayed.jl")
include("structs/ObjectSetting.jl")
include("structs/Object.jl")
include("structs/Transitions.jl")
Expand Down Expand Up @@ -204,6 +205,11 @@ end
# finally objects
flatten!(objects::Array{AbstractObject}, object::Object) = push!(objects, object)


const STARTED_RENDERING = [
false
]

"""
render(
video::Video;
Expand Down Expand Up @@ -253,6 +259,8 @@ function render(
postprocess_frames_flow = identity,
postprocess_frame = default_postprocess,
)

STARTED_RENDERING[1] = true
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be set to false at the end again

Copy link
Member Author

Choose a reason for hiding this comment

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

I added it at the end, maybe it can be reset within the empy_CURRENT_constants() after naming it CURRENTLY_RENDERING.

Copy link
Member Author

Choose a reason for hiding this comment

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

once this works in general

Copy link
Member Author

Choose a reason for hiding this comment

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

  • changed STARTED_RENDERING to CURRENTLY_RENDERING

  • didn't move CURRENTLY_RENDERING[1] = false inside empty_CURRENT_variables because the latter is not called if pathname is empty, I don't know if there is a reason for that. if not I can move it inside it and make it a bit cleaner.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should call it in all cases.

layers = video.layers
objects = video.objects
frames = preprocess_frames!(video)
Expand Down
25 changes: 25 additions & 0 deletions src/object_values.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ val(x) = get_value(x)
get_position(p::Point) = p
get_position(t::Transformation) = t.point

"""
get_delayed_position(obj::Object)

In principle this is similar to [`get_position`](@ref) however, unlike that
one it gets evaluated the first time is called after the rendering has started.
"""
function get_delayed_position(obj::Object)
DelayedPosition(obj, nothing, false)
end

"""
get_position(obj::Object)

Expand All @@ -32,13 +42,28 @@ function get_position(obj::Object)
return get_position(obj.result[1])
end

function get_position(p::DelayedPosition)
if STARTED_RENDERING[1] && !p.called
p.called = true
p.position = get_position(p.obj)
end
return p.position
end

"""
pos(x)

`pos` is just a short-hand for [`get_position`](@ref)
"""
pos(x) = get_position(x)

"""
delayed_pos(x)

`delayed_pos` is just a short-hand for [`get_delayed_position`](@ref)
"""
delayed_pos(x) = get_delayed_position(x)

# As it is just the number tuple -> return it
get_scale(x::Tuple{<:Number,<:Number}) = Scale(x...)

Expand Down
5 changes: 5 additions & 0 deletions src/structs/Delayed.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mutable struct DelayedPosition
obj
gpucce marked this conversation as resolved.
Show resolved Hide resolved
position
called
end
6 changes: 3 additions & 3 deletions src/structs/Transitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
=#

struct Translation <: AbstractTransition
from::Union{Object,Point}
to::Union{Object,Point}
from::Union{Object,Point,DelayedPosition}
Wikunia marked this conversation as resolved.
Show resolved Hide resolved
to::Union{Object,Point,DelayedPosition}
end
gpucce marked this conversation as resolved.
Show resolved Hide resolved

"""
Expand All @@ -29,7 +29,7 @@ act!(obj, Action(1:50, anim_translate(10, 10)))
"""
anim_translate(x::Real, y::Real) = anim_translate(Point(x, y))
anim_translate(tp::Point) = Translation(O, tp)
anim_translate(fp::Union{Object,Point}, tp::Union{Object,Point}) = Translation(fp, tp)
anim_translate(fp::Union{Object,Point,DelayedPosition}, tp::Union{Object,Point,DelayedPosition}) = Translation(fp, tp)

struct Rotation{T<:Real} <: AbstractTransition
from::T
Expand Down