Re: [R] playing with R: make a animated GIF file...

From: Tuszynski, Jaroslaw W. <JAROSLAW.W.TUSZYNSKI_at_saic.com>
Date: Thu 06 Oct 2005 - 22:23:05 EST


See write.gif function in caTools.

Jarek

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of klebyn Sent: Wednesday, October 05, 2005 8:05 PM To: r-help@stat.math.ethz.ch
Subject: [R] playing with R: make a animated GIF file...

Hello all

I am playing with R for to make a animated GIF.

any suggestions, improvements are welcome :-)

case somebody could help me, i thanks!

Cleber N. Borges ( klebyn )

my objective:

(steps TODO)


  1. to save PNG files;

-----> i don't know the best way to make this;

2) transform the PNG files into GIF files (easy! no problem! ... i think ...)

3) reload the GiF files in R and use the caTools package to make a animated GIF.


############################   the code

######## reverse the STRING

strReverse <- function(x) sapply(lapply(strsplit(x, NULL), rev), paste, collapse="")

######## logotype to animate

yourLogo = "Is Nice to play with R-package "

logoWidth = 1.5
logoHeight = 2.5

L = nchar(yourLogo)

TrigSplit = 360 / L

yourLogo = strReverse(yourLogo)

posx = numeric(L)
posy = numeric(L)

for( i in 0:L){
posx[i] = logoHeight * sin(i * TrigSplit * pi / 180) posy[i] = logoWidth * cos(i * TrigSplit * pi / 180) }

max_x = max(posx)*1.1
max_y = max(posy)*3

min_x = min(posx)*1.1
min_y = min(posy)*3

cex = 2/(posy + 2)

idx = 1:L

for(j in 1:L-1) {

###################file = paste("CQM_",j,".png",sep="")

###################png(filename=file, bg="transparent")

plot(0,t='n', xlim=c(min_x,max_x), ylim=c(min_y,max_y), axes=FALSE, ann=FALSE, font=3 )

for( i in 1:L){text(x=posx[i], y=posy[i], labels=substr(yourLogo,idx[i],idx[i]), col='blue', cex=cex[i] ) }

idx = (append(idx[L],idx))[1:L]

Sys.sleep(0.2)

###################dev.off()

}

############## final code



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Oct 06 22:25:34 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:24:36 EST