Last active
March 11, 2019 11:03
-
-
Save wonderburg7/764d4b337bb9655323495c382dfce2e4 to your computer and use it in GitHub Desktop.
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
float radius = 28*4; | |
float x, y, xt = 16, xto = xt, yt = 6, xt2 = xt+20, xto2 = xt2; | |
//float xt3 = 0, xto3 = xt3, yt3 = bottomCutOff-6; | |
float rightTriangleSideSaver = 0; | |
float rightTriangleSideSaver2 = 0; | |
float rightTriangleSideSaver3 = 0; | |
float topCutOff = yt; | |
int bottomCutOff = 35; | |
void setup() | |
{ | |
size( 4000, 4000 ); | |
fill(42, 42, 42); | |
background(201, 206, 189); | |
noStroke(); | |
x = -radius; | |
y = -(radius*sin(TWO_PI+((TWO_PI/6)*2))); | |
noLoop(); | |
} | |
void draw() | |
{ | |
for (int i = 0; i < (width/radius)+radius*2; i++) { | |
for (int j = 0; j < (width/radius)+radius*2; j++) { | |
int coin2 = int(random(1, 5)); | |
if (coin2 == 0) { | |
fill(201, 206, 189); | |
} else if (coin2 == 1) { | |
fill(178, 188, 170); | |
} else if (coin2 == 2) { | |
fill(131, 142, 131); | |
} else if (coin2 == 4) { | |
fill(108, 96, 97); | |
} else { | |
fill(100, 64, 62); | |
} | |
// top and bottom cut off | |
if (i < topCutOff) { | |
fill(201, 206, 189); | |
} else if (i > bottomCutOff) { | |
fill(201, 206, 189); | |
} | |
// makes the diagonal downwards and right line of the triangle | |
if (x > radius*xt && i >= yt && i <= bottomCutOff) { | |
fill(201, 206, 189); | |
// fill(0,0,0); | |
if (j%2==0) { | |
xt++; | |
} | |
rightTriangleSideSaver = xt; | |
} | |
/* // bottom left corner cut off | |
if (x > radius*xt3 && i >= yt3 && i <= bottomCutOff) { | |
fill(201, 206, 189); | |
// fill(0,0,0); | |
if (j%2==0) { | |
xt3++; | |
} | |
rightTriangleSideSaver3 = xt3; | |
}*/ | |
// makes the diagonal downwards and left line of the triangle | |
if (x < radius*xt2 && i >= yt && i <= bottomCutOff) { | |
fill(201, 206, 189); | |
// fill(0,0,0); | |
if (j%2==0) { | |
xt2--; | |
} | |
rightTriangleSideSaver2 = xt2; | |
} | |
if (j%2==0) { | |
beginShape(); | |
vertex(x, y); | |
vertex(x+radius*cos(TWO_PI), y+radius*sin(TWO_PI)); | |
vertex(x+radius*cos(TWO_PI+(TWO_PI/6)), y+radius*sin(TWO_PI+(TWO_PI/6))); | |
endShape(); | |
x += radius; | |
} else { | |
//makes the right side a straight line | |
if (xt == rightTriangleSideSaver && xt == xto && i <= bottomCutOff) { | |
coin2 = int(random(1, 5)); | |
if (coin2 == 0) { | |
fill(201, 206, 189); | |
} else if (coin2 == 1) { | |
fill(178, 188, 170); | |
} else if (coin2 == 2) { | |
fill(131, 142, 131); | |
} else if (coin2 == 4) { | |
fill(108, 96, 97); | |
} else { | |
fill(100, 64, 62); | |
} | |
} | |
beginShape(); | |
vertex(x, y); | |
vertex(x+(radius*cos(TWO_PI+(TWO_PI/6))), y+(radius*sin(TWO_PI+(TWO_PI/6)))); | |
vertex(x+(radius*cos(TWO_PI+(TWO_PI/3))), y+(radius*sin(TWO_PI+(TWO_PI/3)))); | |
endShape(); | |
} | |
} | |
y = y+radius*sin(TWO_PI+((TWO_PI/6)*2)); | |
//seems to make the diagonal cut off happen at the right angle | |
if (i%2==0) { | |
xto++; | |
} | |
xto2--; | |
// makes the xt value come back down to the right value for the next line | |
xt = xto; | |
xt2=xto2; | |
if (i % 2 == 0) { | |
x = -(radius/2); | |
} else { | |
x = -radius; | |
} | |
} | |
save("triangles.png"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment