Control double buffering of graphics window for dynamic graphics

DESCRIPTION:

Allows you to draw on invisible graphics buffer and copy that buffer to visible window. This can give the illusion of moving pictures because you don't see the screen get erased and redrawn.

USAGE:

double.buffer(action) 

REQUIRED ARGUMENTS:

action
One of the strings "back", "copy", or "front".

VALUE:

NULL is returned invisibly.

DETAILS:

If action is "back" then all future graphics will be drawn to an invisible graphics buffer and the current graphics on the screen will remain unchanged. If action is "copy" then that invisible buffer is copied to the graphics window, replacing the graphics that might be on the window. If action is "front" then all future graphics will be drawn on the graphics window.

When using double buffering, you should make sure that you call double.buffer("front") at the end so that future graphics get drawn on the visible graphics window.

NOTE:

This function currently only works with the motif() graphics device. It is experimental and may be changed or withdrawn in the future.

While drawing on the invisible back buffer the visible window is not properly refreshed when it is uncovered. There also may be some problems when resizing the window, but they should be fixed by the time you call double.buffer("copy") or double.buffer("front") .

EXAMPLES:

# Display the tail of a simulated time series as it evolves 
test.double.buffer <- function(n = 100, m = 50) { 
        on.exit(double.buffer("front")) 
        x <- runif(100) 
        plot(x, type = "l") 
        for(i in 1:n) { 
                double.buffer("back") 
                x[1:99] <- x[2:100] 
                x[100] <- mean(x[(100 - m + 1):100]) + runif(1)/3 
                plot(x, type="l", main=paste("Iteration", i)) 
                double.buffer("copy") 
        } 
} 
motif() 
test.double.buffer()