rp.line {rpanel}R Documentation

Draws a line on an rpanel image

Description

This draws a line connecting the pixel locations x1, y1 to x2, y2 on the specified image. The colour and width of the line can be controlled.

Usage

rp.line(panel, image, x1, y1, x2, y2, ..., color = "black", width = 2, id = 'rpline')

Arguments

panel the panel containing the image. This may be passed as a panelname string or the panel object itself.
image the image on which the line should be drawn.
x1 the horizontal first position of start of the line.
y1 the vertical first position of start of the line.
x2 the horizontal final position of end of the line.
y2 the vertical final position of end of the line.
... any further parameters.
color the colour of the line. The default is "black".
width the width of the line. The default is 2.
id the identifier of the line created.

Details

The function action should take one argument, which should be the panel to which the line is attached.

Value

If the parameter panel is the panelname string the same string is returned. If the panel object is used the altered panel is assigned to both the calling level and global level.

References

rpanel: Simple interactive controls for R functions using the tcltk library (http://www.stats.gla.ac.uk/~adrian/research-reports/rpanel.ps)

See Also

rp.tkrplot,rp.image

Examples

click.capture <- function(panel,x,y) {
  if (is.null(panel$x)) { 
    panel$x <- as.numeric(x)
    panel$y <- as.numeric(y) 
  } else { 
    rp.line(panel, gulls.image, panel$x, panel$y, as.numeric(x), as.numeric(y), width=3, id = "current")
    panel$x <- as.numeric(x)
    panel$y <- as.numeric(y)
  }
  panel
}
gulls.panel <- rp.control()
image.file <- file.path(system.file(package = "rpanel"), "images", "gulllmks.gif")
rp.image(gulls.panel, image.file, id = "gulls.image", action = click.capture)

[Package rpanel version 1.0-3 Index]