Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Program to generate a Pentalath/Ndengrod board using original layout
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
You can’t perform that action at this time.