Last active
February 18, 2024 10:43
-
-
Save lgatto/4fa4b3a8a6668a6b755b47da40d8ca81 to your computer and use it in GitHub Desktop.
Reproducing The Grid exhibition poster
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
## See https://lgatto.github.io/the-grid-in-r/ | |
plotSquare <- function(x, y, width) { | |
x1 <- x - (width / 2) | |
y1 <- y - (width / 2) | |
x2 <- x1 + width | |
y2 <- y1 + width | |
rect(x1, y1, x2, y2) | |
} | |
## Number of squares | |
nsq <- 10 | |
## amount of square jittering | |
amount <- 1.2 | |
## border ratio | |
ratio <- 0.2 | |
sq_w <- (100 / nsq) * (1 - ratio) | |
border_w <- (100 - (nsq * sq_w)) / (nsq + 1) | |
pos <- seq(border_w, 100 - border_w, | |
length.out = nsq) | |
par(mar = rep(1, 4), oma = rep(0, 4)) | |
plot(-2:(100 - border_w + 2), -2:(100 - border_w + 2), | |
type = "n", axes = FALSE, | |
xlab = "", ylab = "", | |
frame.plot = FALSE) | |
for (y in pos) { | |
pos_x <- jitter(rep(y, nsq), amount = amount) | |
pos_y <- jitter(pos, amount = amount) | |
plotSquare(pos_x, pos_y, sq_w) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment