Skip to content

Commit

Permalink
add tests for movies
Browse files Browse the repository at this point in the history
  • Loading branch information
cormullion committed Apr 6, 2024
1 parent 14a7e86 commit 6c271e9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/animate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ end
pathname = "",
tempdirectory = "")
Create all the frames of the movie, using the array of scenes
in `scenelist`.
Create all the frames of the `movie``, using the array of scenes
defined in `scenelist`.
If `creategif` is `true`, also create an animated GIF (".gif").
If `createmovie` is `true`, also create a movie (".mkv", ".mp4", ".webm") file.
If `createmovie` is `true`, also create a movie (".mkv", ".mp4", or ".webm") file.
The file will be stored in the `pathname` keyword argument, or otherwise in a
temporary directory.
Expand Down Expand Up @@ -220,7 +220,7 @@ function animate(movie::Movie, scenelist::Array{Scene,1};
@info("... $(filecounter-1) frames saved in directory:\n\t $(tempdirectory)")

if creategif == false && createmovie == false
@info "to create a movie or GIF, use `creategif = true`` or `createmovie=true`."
@info "to create a GIF or a movie, use `creategif = true` or `createmovie=true`."
return true # we're done
end

Expand Down Expand Up @@ -282,6 +282,7 @@ function animate(movie::Movie, scenelist::Array{Scene,1};
pathname = targetdir * movieformat
end
_make_video(movieformat, pathname, framerate, tempdirectory)
return true
end
end

Expand Down
28 changes: 28 additions & 0 deletions test/animation-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,32 @@ end
end
end

@testset "test output" begin
demo = Movie(100, 100, "test")
function frame(scene, framenumber)
sethue("purple")
eased_n = scene.easingfunction(framenumber, 0, 1, scene.framerange.stop)
circle(Point(-180 + (360 * eased_n), -20), 10, :fill)
end
mktempdir() do tmpdir
cd(tmpdir) do
# true if no gif
@test animate(demo, [Scene(demo, frame, 0:20, easingfunction = easeinsine)],
creategif = false) == true
# return gif
ag = animate(demo, [Scene(demo, frame, 0:20, easingfunction = easeinsine)], creategif = true)
@test ag isa Luxor.AnimatedGif
# true if movie
@test animate(demo, [Scene(demo, frame, 0:10)], createmovie = true) == true
@test animate(demo, [Scene(demo, frame, 0:10)], createmovie = true, creategif = false) == true
animate(demo, [Scene(demo, frame, 0:10)], createmovie = true, pathname = "temp")
@test isfile("temp.mkv")
animate(demo, [Scene(demo, frame, 0:10)], createmovie = true, pathname = "temp.mp4")
@test isfile("temp.mp4")
animate(demo, [Scene(demo, frame, 0:10)], createmovie = true, pathname = "temp.webm")
@test isfile("temp.mp4")
end
end
end

println("...finished animation tests")

0 comments on commit 6c271e9

Please sign in to comment.