Draws a line on an rpanel image

Share:

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

1
rp.line(panel, imagename, 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.

imagename

the image on which the line should be drawn.

x1

the horizontal first position of start of the line in pixel co-ordinates.

y1

the vertical first position of start of the line in pixel co-ordinates.

x2

the horizontal final position of end of the line in pixel co-ordinates.

y2

the vertical final position of end of the line in pixel co-ordinates.

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 argument 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 panel's environment level.

Note

In version 1.0, the former argument image has been renamed name to be consistent with the rest of rpanel.

References

rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.

See Also

rp.tkrplot,rp.image

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
  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, imagename=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, imagename="gulls.image", action = click.capture)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.