Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Program to generate a Yavalath board
# Yavalath board
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)
how_many <- 5
for (i in 5:9) {
for (j in 1:i) { # x-coordinate
h <- hexdf(mid = c((i/2-j)*1.5,-i*1.5))
p <- p + geom_polygon(data = h, fill = "lightblue1", colour = "black", lwd = 3)
}
}
for (i in 8:5) {
for (j in 1:i) { # x-coordinate
ii <- 18-i
h <- hexdf(mid = c((i/2-j)*1.5,-ii*1.5))
p <- p + geom_polygon(data = h, fill = "lightblue1", colour = "black", lwd = 3)
}
}
#pdf("pentalath.pdf", paper = "a4r", title = "Pentalath")
setwd("~")
png("yavalath.png", width = 3508, height = 2480)
p <- p + annotate("text", x = -1, y = -5,
label = "Yavalath", colour = "black", size = 96)
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.