Consider the following:

par(mar=c(0,0,0,0),xaxs = 'i',yaxs='i')
plot.new()
for(i in 1:20)
  {
  z <- matrix(runif(256*256), ncol=256)
  dev.hold()
  image(z, col=grey(0:255/255),zlim=c(0,1),useRaster=TRUE)
  dev.flush()
  Sys.sleep(.1)
  }

I would like to continuously display the animation until a mouse click
happens. Obviously, locator() can't be used for this, because it will halt
the animation while waiting for the mouse click. So something like this
won't work:

while((r<-locator(n=1)) == NULL)
  {
  z <- matrix(runif(256*256), ncol=256)
  dev.hold()
  image(z, col=grey(0:255/255),zlim=c(0,1),useRaster=TRUE)
  dev.flush()
  Sys.sleep(.1)
  }

Can somebody suggest a way to get user input while displaying the
animation? I am willing to use a keypress if not the mouse. Essentially, I
need an input routine that does not wait for a response but just checks at
one instant (like kbhit in C).

Thanks very much for any help.

Stan

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to