Open ugroempi opened 6 years ago
Not sure, might be spurious, from an unclosed device, and thus not a problem of this package. Best, Ulrike
I tested your demo twice with img.name = "blacksquare" or img.name = "blackcircle", and keeping the html file name as same, I didn't see any a placeholder image.
I believe that a file called blacksquare0.png
was created from an (erroneously) open device while running the code for creating the blackcircle1.png
... files (and possibly, while img.name
was not yet reset to blackcircle
); the top of the html file then showed a one-slide animation of this stray file, before showing the intended animation of the circles. This certainly was not a standard condition, and saveHTML
cannot be expected to foresee it.
Maybe this could be avoided by setting img.name
in a separate call to ani.options
before calling saveHTML
, rather than as an option within saveHTML
?
Best, Ulrike
Yes, I think there are some problems in saveHTML
, I am checking it now. I didn't find blacksquare0.png
in my directory. I am checking why the two animations were displayed in one html file.
Here is my code.
ani.options(imgdir="images", ani.dev="png", use.dev=TRUE, interval=0.1, nmax=38)
greys20 <- grey.colors(20, start=0.2, end=0.9)
saveHTML(
for (i in c(20:1, 2:19)){
plot.new()
par(mar=rep(1,4), bg="grey20")
plot.window(xlim=c(-1.25,1.25), ylim=c(-1.25,1.25), asp=1)
symbols(0, 0, circles=1, inches=FALSE,
bg=greys20[i], fg=greys20[i], add=TRUE)},
img.name = "blacksquare", htmlfile = "blackmovie.html",
title="Crude animation", navigator=FALSE)
ani.options(imgdir="images", ani.dev="png", use.dev=TRUE, interval=0.1, nmax=38)
greys20 <- grey.colors(20, start=0.2, end=0.9)
saveHTML(
for (i in c(20:1, 2:19)){
plot.new()
par(mar=rep(1,4), bg="grey20")
plot.window(xlim=c(-1.25,1.25), ylim=c(-1.25,1.25), asp=1)
symbols(0, 0, circles=1, inches=FALSE,
bg=greys20[i], fg=greys20[i], add=TRUE)},
img.name = "blackcircle", htmlfile = "blackmovie.html",
title="Crude animation", navigator=FALSE)
In saveHTML
, if we create multiple animations with same htmlfile
name, we try to add new animation after the old animation in the same file, although we don't show any append
option.
## try to append to the HTML file if it exists
html = if (file.exists(htmlfile)) {
readLines(htmlfile)
} else {
readLines(system.file('misc', 'scianimator', 'index.html', package = 'animation'))
}
I see! I observe that appending does not happen for the same img.name
, only if the img.name
is different with the same htmlfile
. This is something I would not want to happen unasked; why not have an append
option with default TRUE
and if (file.exists(htmlfile) && append)
? At least, the behavior should be explained in the documentation, I think.
Best, Ulrike
I encountered some problems arising from left-overs of an old saved html file of the same name. The situation: I ran the code below initially with black squares, with
img.name="blacksquare"
. I then changed to circles, changing the name toimg.name="blackcircle"
, but keeping the html file name. Viewing the html file in the browser showed an animation at the top which tried to find file "blacksquare1.png" (but of course didn't and displayed a placeholder instead), and below that the intended animation with the circles (the Rstudio window did not display either of the animations properly); thus,saveHTML
behaved as though there were an append option somehow, which seems like a bug to me.Best, Ulrike
The code:
ani.options(imgdir="images", ani.dev="png", use.dev=TRUE, interval=0.1, nmax=38)
greys20 <- grey.colors(20, start=0.2, end=0.9)
saveHTML(
for (i in c(20:1, 2:19)){
plot.new()
par(mar=rep(1,4), bg="grey20")
plot.window(xlim=c(-1.25,1.25), ylim=c(-1.25,1.25), asp=1)
symbols(0, 0, circles=1, inches=FALSE,
bg=greys20[i], fg=greys20[i], add=TRUE)},
img.name = "blackcircle", htmlfile = "blackmovie.html",
title="Crude animation", navigator=FALSE)