draw | R Documentation |
Draw a geometric object on the current plot.
draw(x, ...)
## S3 method for class 'Triangle'
draw(x, ...)
## S3 method for class 'Circle'
draw(x, npoints = 100L, ...)
## S3 method for class 'Arc'
draw(x, npoints = 100L, ...)
## S3 method for class 'Ellipse'
draw(x, npoints = 100L, ...)
## S3 method for class 'EllipticalArc'
draw(x, npoints = 100L, ...)
## S3 method for class 'Line'
draw(x, ...)
x |
geometric object ( |
... |
arguments passed to |
npoints |
integer, the number of points of the path |
# open new plot window
plot(0, 0, type="n", asp = 1, xlim = c(0,2.5), ylim = c(0,2.5),
xlab = NA, ylab = NA)
grid()
# draw a triangle
t <- Triangle$new(c(0,0), c(1,0), c(0.5,sqrt(3)/2))
draw(t, col = "blue", lwd = 2)
draw(t$rotate(90, t$C), col = "green", lwd = 2)
# draw a circle
circ <- t$incircle()
draw(circ, col = "orange", border = "brown", lwd = 2)
# draw an ellipse
S <- Scaling$new(circ$center, direction = c(2,1), scale = 2)
draw(S$scaleCircle(circ), border = "grey", lwd = 2)
# draw a line
l <- Line$new(c(1,1), c(1.5,1.5), FALSE, TRUE)
draw(l, col = "red", lwd = 2)
perp <- l$perpendicular(c(2,1))
draw(perp, col = "yellow", lwd = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.