Skip to content

Instantly share code, notes, and snippets.

@switchswap
Created August 5, 2021 07:57
Show Gist options
  • Save switchswap/69015734bcfcbd7dd62457fc853f5aeb to your computer and use it in GitHub Desktop.
Save switchswap/69015734bcfcbd7dd62457fc853f5aeb to your computer and use it in GitHub Desktop.
Progamatic Glyphs
void drawGlyph(int startX, int startY, int stepSize) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
int orientation = int(random(2));
int currX = startX + (i * stepSize);
int currY = startY + (j * stepSize);
if (orientation == 0) {
// Draw left diagonal
line(currX, currY, currX + stepSize, currY + stepSize);
}
else {
// Draw right diagonal
line(currX + stepSize, currY, currX, currY + stepSize);
}
}
}
}
void drawPage(int startX, int startY, int glyphSpacing, int glyphStepSize) {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 8; j++) {
drawGlyph(startX + (i * glyphSpacing) , startY + (j * glyphSpacing), glyphStepSize);
}
}
}
void setup() {
size(400, 650);
randomSeed(0);
strokeCap(PROJECT);
strokeWeight(5);
//drawPage(5, 5, 60, 20); // One block
drawPage(5, 5, 80, 20); // Properly spaced
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment