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

arrange-animate objects vertically/horizontally #490

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

ArbitRandomUser
Copy link
Contributor

@ArbitRandomUser ArbitRandomUser commented Aug 17, 2022

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 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)?
  • Did I properly add Javis dependencies to the Project.toml + set an upper bound of the dependency (if applicable)?
  • Did I properly add test dependencies to the test directory (if applicable)?
  • 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 #

How did you address these issues with this PR? What methods did you use?

P.R allows objects to be arranged around other objects or a point

example

using Javis
video = Video(1000,1000)
nframes=150
Background(1:nframes,(args...) -> begin
               background("black")
               sethue("white")
           end
              )
obj1 = Object(1:nframes,(args...)-> begin
                  box(O,100,100,:stroke)
                  return O
                  end,
                  rand(BoundingBox())
                 )

obj2 = Object(1:nframes,(args...)-> begin
                  circle(O,50,:stroke)
                  return O
                  end,
                  rand(BoundingBox())
                 )

obj3 = Object(1:nframes,(args...)-> begin
                  star(O,50,5,0.5,action=:stroke)
                  return O
                  end,
                  rand(BoundingBox())
                 )

showpoint = Object(1:nframes,(args...)->circle(O+(20,50),5,:fill))
objlist = [obj1,obj2,obj3]

act!(10, Javis.arrange(10:nframes÷2,objlist,O+(20,50);gap=10,dir=:vertical))
act!(obj3,Action(1:10,anim_scale(2)))

act!(nframes÷2+1 , Javis.arrange(nframes÷2+1:nframes-10,objlist,O+(20,50);gap=10,dir=:horizontal ))
#
render(video, pathname="testarrange.gif")
run(`mpv testarrange.gif`)

testarrange

@ArbitRandomUser ArbitRandomUser changed the title initial commit animate arrange objects vertically/horizontally Aug 17, 2022
@codecov-commenter
Copy link

codecov-commenter commented Aug 17, 2022

Codecov Report

Merging #490 (b252935) into main (1e74392) will decrease coverage by 0.46%.
The diff coverage is 77.85%.

@@            Coverage Diff             @@
##             main     #490      +/-   ##
==========================================
- Coverage   77.74%   77.28%   -0.47%     
==========================================
  Files          38       40       +2     
  Lines        1991     2210     +219     
==========================================
+ Hits         1548     1708     +160     
- Misses        443      502      +59     
Impacted Files Coverage Δ
src/runtimefuncs.jl 35.71% <35.71%> (ø)
src/arrange.jl 81.35% <81.35%> (ø)
src/Javis.jl 96.76% <100.00%> (-0.17%) ⬇️
src/action_animations.jl 95.37% <0.00%> (-0.44%) ⬇️
src/Shape.jl 0.00% <0.00%> (ø)
src/backgrounds.jl 100.00% <0.00%> (ø)
src/luxor_utils.jl 100.00% <0.00%> (ø)
src/structs/JPath.jl 100.00% <0.00%> (ø)
src/util.jl 97.36% <0.00%> (+0.05%) ⬆️
... and 6 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ArbitRandomUser ArbitRandomUser marked this pull request as ready for review August 18, 2022 06:54
@ArbitRandomUser ArbitRandomUser changed the title animate arrange objects vertically/horizontally arrange-animate objects vertically/horizontally Aug 18, 2022
src/arrange.jl Outdated


"""
arrange()
Copy link
Member

Choose a reason for hiding this comment

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

You can add the parameters here

@ArbitRandomUser ArbitRandomUser marked this pull request as draft August 22, 2022 17:02
@ArbitRandomUser ArbitRandomUser marked this pull request as ready for review August 23, 2022 04:17
@ArbitRandomUser
Copy link
Contributor Author

ArbitRandomUser commented Sep 2, 2022

@Sov-trotter @Wikunia @gpucce @TheCedarPrince
Ive added some more features , to align objects in variuos directions
around a point. do take a look and let me know what improvments i can make to this.

using Javis
video = Video(1000,1000)
nframes=250
groundj = Background(1:nframes,(args...) -> begin
               background("black")
               sethue("white")
           end)
objj1 = Object(1:nframes,(args...)-> begin
                  box(O,100,100,:stroke)
                  return O
                  end,
                  Point(100,150)
                 )

objj2 = Object(1:nframes,(args...)-> begin
                  circle(O,50,:stroke)
                  return O
                  end,
                  Point(-100,250)
                 )

objj3 = Object(1:nframes,(args...)-> begin
                  #rotate(2π/12)
                  box(O,100,50,:stroke)
                  #star(O,50,3,0.5,0.0,:stroke)
                  return O
                  end,
                  Point(-200,-150)
                 )


objlist = [objj1,objj2,objj3]
frameno = 2
Object(1:nframes,(args...)->circle(O,5,:fill))
#act!(frameno,arrange(frameno:frameno+25,objlist,O;gap=0,dir=:horizontal,align=:left,towards=:top))
for dir in (:horizontal,:vertical)
    global frameno
    for align in (:left,:right)
        for towards in (:top,:bottom)
            act!(frameno,arrange(frameno:frameno+25,objlist,O;gap=0,dir=dir,align=align,towards=towards))
            frameno=frameno+30
        end
    end
end

render(video,pathname="testarrange3.gif")
run(`mpv testarrange3.gif`)

testarrange3

@@ -376,6 +378,8 @@ function render(

# clear all CURRENT_* constants to not accidentally use a previous video when creating a new one
empty_CURRENT_constants()
haskey(video.defs, :RuntimeFunctionDict) ? empty!(video.defs[:RuntimeFunctionDict]) :
nothing
Copy link
Member

Choose a reason for hiding this comment

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

This can go in the same line above I guess. But if it's the output of JuliaFormatter then fell free to resolve.

at render time RuntimeFunctionMap[frame] is checked and every Func
in the array is called with `func(frame)`
"""
#videoRuntimeFunctionDict = Dict{Int,Array{Function}}()
Copy link
Member

Choose a reason for hiding this comment

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

Is this still needed?

@ArbitRandomUser
Copy link
Contributor Author

P.R also adds ability to arrange around objects now

using Javis
video = Video(1000,1000)
nframes=300
groundj = Background(1:nframes,(args...) -> begin
               background("black")
               sethue("white")
           end)
objj1 = Object(1:nframes,(args...)-> begin
                  sethue("yellow")
                  box(O,100,100,:stroke)
                  text("Target")
                  return O
                  end,
                  O-100
                 )

objj2 = Object(1:nframes,(args...)-> begin
                  circle(O,35,:stroke)
                  return O
                  end,
                  Point(-100,250)
                 )

objj3 = Object(1:nframes,(args...)-> begin
                  #rotate(2π/12)
                  box(O,150,50,:stroke)
                  #star(O,50,3,0.5,0.0,:stroke)
                  return O
                  end,
                  Point(-200,-150)
                 )


objlist = [objj2,objj3]
frameno = 20
for dir in (:horizontal,:vertical)
    global frameno
    for halign in (:left,:right)
        for valign in (:top,:bottom)
            act!(frameno,arrange(frameno:frameno+25,objlist,objj1;gap=0,dir=dir,halign=halign,valign=valign))
            frameno=frameno+30
        end
    end
end

render(video,pathname="testarrange_obj.gif")
run(`mpv testarrange_obj.gif`)

testarrange_obj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants