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

Tuszynski, Jaroslaw W. JAROSLAW.W.TUSZYNSKI at saic.com
Thu Oct 6 14:23:05 CEST 2005


See write.gif function in caTools.

Jarek 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of klebyn
Sent: Wednesday, October 05, 2005 8:05 PM
To: r-help at 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 at 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




More information about the R-help mailing list