Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
polygon <- function(n) {
x = accumulate(1:(n-1), ~.x+cos(.y*2*pi/n), .init = 0),
y = accumulate(1:(n-1), ~.x+sin(.y*2*pi/n), .init = 0),
xend = accumulate(2:n, ~.x+cos(.y*2*pi/n), .init = cos(2*pi/n)),
yend = accumulate(2:n, ~.x+sin(.y*2*pi/n), .init = sin(2*pi/n)))
ggplot(polygon(5) + geom_segment(aes(x=x, y=y, xend=xend, yend=yend)) + theme_void() + coord_equal()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.