Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gamesbyangelina/b2d309407295d329cf37fc3bee28ad79 to your computer and use it in GitHub Desktop.
Save gamesbyangelina/b2d309407295d329cf37fc3bee28ad79 to your computer and use it in GitHub Desktop.
void setup(){
//Make the canvas this big
size(1000,375);
int size = 50;
int canvasSize = 1000;
//Set the background color
background(76,55,25);
//Set the fill
fill(237,191,128);
//Turn off outlines for shapes
noStroke();
//Turn off anti-aliasing
noSmooth();
int i=0;
int j=0;
//This converts the width of the canvas to an RGB value so left-to-right we go across the whole color range
int rgbConversion = canvasSize/255;
//Iterate over the whole canvas in 'size' chunks
for(i=0; i<canvasSize; i+=size){
for(j=0; j<canvasSize; j+=size){
//Set the fill based on how far across the screen we are
fill(i/rgbConversion,100,150);
//Draw a triangle pointing right
triangle(i, j, i+size, j-size/2, i+size, j+size/2);
//Set the secondary fill to a similar colour (tweaked the G value so it's subtly darker)
fill(i/rgbConversion,150,200);
//Draw a triangle above it pointing 'backwards'
triangle(i, j, i+size, j+size/2, i, j+size);
}
}
//One little extra row at the bottom to fill in
for(i=0; i<canvasSize; i+=size){
fill(i/rgbConversion,100,150);
triangle(i, j, i+size, j-size/2, i+size, j+size/2);
}
//Done
save("test.png");
}
void draw() {
}
boolean Near(float x, float y, float cx, float cy, float lim){
return sqrt(pow(x-cx, 2)+pow(y-cy, 2)) < lim;
}
void polygon(float x, float y, float radius, int npoints) {
float angle = TWO_PI / npoints;
beginShape();
for (float a = 0; a < TWO_PI; a += angle) {
float sx = x + cos(a) * radius;
float sy = y + sin(a) * radius;
vertex(sx, sy);
}
endShape(CLOSE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment