Scale polygons around their center

scale_polygon(poly, scaling)

Arguments

poly

a data frame defining a polygon (x and y coordinates)

scaling

a numeric vector that defines the scaling factor

Value

data.frame defining a scaled polygon

Examples

scale_polygon(data.frame(x = c(1, 2, 3), y = c(1, 2, 1)), 2)
#> x y #> 1 0 0.6666667 #> 2 2 2.6666667 #> 3 4 0.6666667
poly <- data.frame(x = c(1, 1, 0, 0), y = c(1, 0, 0, 1)) library(ggplot2) ggplot(data = NULL, aes(x = x, y = y)) + geom_polygon(data = poly, fill = "black") + geom_polygon(data = scale_polygon(poly, 0.5), fill = "gray") + geom_polygon(data = scale_polygon(poly, 2), alpha = 0.2, fill = "red") + geom_polygon(data = scale_polygon(poly, c(1, 3)), alpha = 0.2, fill = "green") + geom_polygon(data = scale_polygon(poly, c(3, 1)), alpha = 0.2, fill = "blue")