Created
February 25, 2014 13:41
-
-
Save JayH5/9208926 to your computer and use it in GitHub Desktop.
Stripy Processing example
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
int WIDTH = 800; | |
int HEIGHT = 400; | |
int ROWS = 10; | |
int ROW_HEIGHT = 40; | |
int STROKE_WIDTH = 10; | |
void setup() { | |
// This code happens once, right when our sketch is launched | |
size(WIDTH, HEIGHT); | |
background(255); | |
smooth(); | |
table(); | |
data(); | |
} | |
void table() { | |
noStroke(); | |
for (int i = 0; i < ROWS; i++) { | |
if ((i % 2) == 0) { | |
fill(140,190,253); | |
} else { | |
fill(120,170,220); | |
} | |
rect(0, i * ROW_HEIGHT, 100, (i + 1) * ROW_HEIGHT); | |
fill(0); | |
text("fork" + i, 10, i * ROW_HEIGHT + ROW_HEIGHT / 2); | |
} | |
stroke(0); | |
noFill(); | |
for (int i = 0; i < ROWS; i++) { | |
int y = i * ROW_HEIGHT; | |
line(0, y, WIDTH, y); | |
} | |
} | |
void data() { | |
// Lines of random colour | |
int alpha = 30; | |
for (int i = 0; i < ROWS; i++) { | |
strokeWeight(STROKE_WIDTH); | |
strokeCap(ROUND); | |
int colour = color(random(255), random(255), random(255)); | |
stroke(colour, alpha); | |
int rowCentre = i * ROW_HEIGHT + ROW_HEIGHT / 2; | |
line(110, rowCentre, width - 10, rowCentre); | |
// Add some commits | |
strokeWeight(2); | |
strokeCap(SQUARE); | |
stroke(colour, 50); | |
int top = rowCentre - STROKE_WIDTH / 2; | |
int bottom = rowCentre + STROKE_WIDTH / 2; | |
for (int j = 0; j < 200; j++) { | |
int x = ceil(random(110, width - 10)); | |
line(x, top, x, bottom); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment