Small API change to animations
Animation constructor minor fix
This commit is contained in:
parent
dd7b09552a
commit
7b71d9a448
@ -1,19 +1,18 @@
|
|||||||
|
|
||||||
immutable Animation{P<:PlottingObject}
|
immutable Animation
|
||||||
plt::P
|
|
||||||
dir::ASCIIString
|
dir::ASCIIString
|
||||||
frames::Vector{ASCIIString}
|
frames::Vector{ASCIIString}
|
||||||
end
|
end
|
||||||
|
|
||||||
function Animation(plt::PlottingObject)
|
function Animation()
|
||||||
Animation(plt, mktempdir(), ASCIIString[])
|
tmpdir = convert(ASCIIString, mktempdir())
|
||||||
|
Animation(tmpdir, ASCIIString[])
|
||||||
end
|
end
|
||||||
Animation() = Animation(current())
|
|
||||||
|
|
||||||
function frame(anim::Animation)
|
function frame{P<:PlottingObject}(anim::Animation, plt::P=current())
|
||||||
i = length(anim.frames) + 1
|
i = length(anim.frames) + 1
|
||||||
filename = @sprintf("%06d.png", i)
|
filename = @sprintf("%06d.png", i)
|
||||||
png(anim.plt, joinpath(anim.dir, filename))
|
png(plt, joinpath(anim.dir, filename))
|
||||||
push!(anim.frames, filename)
|
push!(anim.frames, filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,11 +28,11 @@ function gif(anim::Animation, fn::@compat(AbstractString) = "tmp.gif"; fps::Inte
|
|||||||
fn = abspath(fn)
|
fn = abspath(fn)
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
||||||
# high quality
|
# high quality
|
||||||
speed = round(Int, 100 / fps)
|
speed = round(Int, 100 / fps)
|
||||||
run(`convert -delay $speed -loop 0 $(anim.dir)/*.png $fn`)
|
run(`convert -delay $speed -loop 0 $(anim.dir)/*.png $fn`)
|
||||||
|
|
||||||
catch err
|
catch err
|
||||||
warn("Tried to create gif using convert (ImageMagick), but got error: $err\nWill try ffmpeg, but it's lower quality...)")
|
warn("Tried to create gif using convert (ImageMagick), but got error: $err\nWill try ffmpeg, but it's lower quality...)")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user