Skip to content

Instantly share code, notes, and snippets.

@MartinMSPedersen
Created January 19, 2019 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinMSPedersen/19d847f2de53fa81299a90c0378ac208 to your computer and use it in GitHub Desktop.
Save MartinMSPedersen/19d847f2de53fa81299a90c0378ac208 to your computer and use it in GitHub Desktop.
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