Created
January 19, 2019 11:33
-
-
Save MartinMSPedersen/f53315b4b749a75a37463b10068e7930 to your computer and use it in GitHub Desktop.
Program to generate a Pentalath/Ndengrod board using original layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
hexdf <- function (size = 1, mid = c(0, 0), angle = 90) { | |
width <- size * 1 | |
height <- size * 0.865 | |
xy <- shape:::getellipse(width, height, mid = mid, dr = 2 * pi/6) | |
tibble::as_tibble(structure(as.data.frame( | |
shape::rotatexy(xy,angle = angle, mid = mid)), class = "data.frame", names = c("x", "y")), validate = FALSE) | |
} | |
hex1 <- hexdf(mid = c(0,0)) | |
p <- ggplot() | |
p <- p + theme_void() | |
p <- p + aes(x = x, y = y) | |
p <- p + coord_cartesian(xlim = c(1,13)*1.5, ylim = -c(-4,9)*1.5) | |
for (j in 0:6) { | |
for (i in 1:(13-j)) { | |
h <- hexdf(mid = c(i*1.5+sqrt(2)*j/2,-j*1.5)) | |
p <- p + geom_polygon(data = h, fill = "lightblue1", colour = "black") | |
} | |
} | |
#pdf("pentalath.pdf", paper = "a4r", title = "Pentalath") | |
setwd("~") | |
png("pentalath.png", width = 3508, height = 2480) | |
p <- p + annotate("text", x = 10, y = 4, | |
label = "Pentalath", colour = "black", size = 128) | |
p | |
dev.off() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment