| canvas | R Documentation |
Functions to make pleasing doodles
canvas()
paradox(
shape,
dist = 0.05,
reverse = FALSE,
cols = colorRampPalette(c("red", "blue"))(40),
debug = FALSE
)
paradoxes(shapes, dist = 0.05, cols = colorRampPalette(c("red", "blue"))(40))
scale_shape(shape, scale = 1, shift = 0)
shape |
a matrix with colums x and y definining a shape to doodle within, can be any closed polygon, but some shapes work better than others. |
dist |
the distance up the adjacent edge where each new line will be drawn, default 0.05 |
reverse |
should the shape be drawn in reverse order (see examples) |
cols |
a palate of colours as a vector of strings interpretable as colours |
debug |
should debug messages be produces (default FALSE) |
shapes |
a list of shapes (polygons) to doodle within |
scale |
if scaling, how much to scale by |
shift |
if scaling, should the shape also be shifted and by how much |
displays a plot
if (interactive()) {
triangle <- cbind(x = c(0, 1, .7), y = c(0, 0.1, 1))
triangle2 <- cbind(x = c(0, 0, .7), y = c(0, 1, 1))
square <- cbind(x = c(0, 1, 1, 0), y = c(0, 0, 1, 1))
canvas()
paradox(square, 0.03)
canvas()
paradox(triangle, 0.042)
paradox(triangle2, 0.042)
canvas()
paradox(scale_shape(square, c(0.5, 1)), 0.03)
paradox(scale_shape(square, c(0.5, 1), c(0.5, 0)), 0.05, reverse = TRUE)
canvas()
dist <- 0.02
paradox(scale_shape(square, .5), dist)
paradox(scale_shape(square, .5, c(0.5, 0)), dist, reverse = TRUE)
paradox(scale_shape(square, .5, .5), dist)
paradox(scale_shape(square, .5, c(0, 0.5)), dist, reverse = TRUE)
canvas()
dist <- 0.02
paradox(scale_shape(square, .5), dist, reverse = TRUE)
paradox(scale_shape(square, .5, c(0.5, 0)), dist, reverse = TRUE)
paradox(scale_shape(square, .5, .5), dist, reverse = TRUE)
paradox(scale_shape(square, .5, c(0, 0.5)), dist, reverse = TRUE)
canvas()
dist <- 0.02
cols1 <- colorRampPalette(c("red", "blue"))(30)
cols2 <- colorRampPalette(c("blue", "red"))(30)
cols3 <- colorRampPalette(c("green", "purple"))(30)
cols4 <- colorRampPalette(c("purple", "green"))(30)
paradox(scale_shape(square, .5), dist,
reverse = TRUE,
cols = c(rbind(cols1, cols2, cols3, cols4))
)
paradox(scale_shape(square, .5, c(0.5, 0)), dist,
reverse = FALSE,
cols = c(rbind(cols3, cols4, cols1, cols2))
)
paradox(scale_shape(square, .5, .5), dist,
reverse = FALSE,
cols = c(rbind(cols1, cols2, cols3, cols4))
)
paradox(scale_shape(square, .5, c(0, 0.5)), dist,
reverse = TRUE,
cols = c(rbind(cols3, cols4, cols1, cols2))
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.