Merge pull request #3660 from t-bltg/anim_glob
Avoid using global variables in animation.jl
This commit is contained in:
commit
86fbb39723
@ -170,18 +170,19 @@ function _animate(forloop::Expr, args...; callgif = false)
|
|||||||
end
|
end
|
||||||
|
|
||||||
push!(block.args, :(if $filterexpr; Plots.frame($animsym); end))
|
push!(block.args, :(if $filterexpr; Plots.frame($animsym); end))
|
||||||
push!(block.args, :(global $countersym += 1))
|
push!(block.args, :($countersym += 1))
|
||||||
|
|
||||||
# add a final call to `gif(anim)`?
|
# add a final call to `gif(anim)`?
|
||||||
retval = callgif ? :(Plots.gif($animsym)) : animsym
|
retval = callgif ? :(Plots.gif($animsym)) : animsym
|
||||||
|
|
||||||
# full expression:
|
# full expression:
|
||||||
esc(quote
|
esc(quote
|
||||||
$freqassert # if filtering, check frequency is an Integer > 0
|
$freqassert # if filtering, check frequency is an Integer > 0
|
||||||
$animsym = Plots.Animation() # init animation object
|
$animsym = Plots.Animation() # init animation object
|
||||||
global $countersym = 1 # init iteration counter
|
let $countersym = 1 # init iteration counter
|
||||||
$forloop # for loop, saving a frame after each iteration
|
$forloop # for loop, saving a frame after each iteration
|
||||||
$retval # return the animation object, or the gif
|
end
|
||||||
|
$retval # return the animation object, or the gif
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user