Inspired by the South Indian – Chettinad’s Athangudi tiles
//Name: Hari Vardhan Sampath
//Section: E
//eMail address: harivars@andrew.cmu.edu
//Project-05
function setup() {
createCanvas(600, 550);
background(0); // black
}
var r = 10; // initialize red
var g = 10; // initialize green
var b = 10; // initialize blue
function draw() {
drawGrid();
noLoop(); // to mainitain gradient
}
function drawGrid() {
var s = 50; //side of the cube
for (var y = 0; y <= height; y += s + s/2) {
var green = 5; //initialize green
for (var x = 0; x <= width; x += s) {
fill(r, g, b);
cube(x, y, s);
r += 3 //increment red
g += 2 //increment green
b += 1 //increment blue
}
r += 2 //increment red
b += 3 //increment blue
}
}
function cube(x, y, s){
// first face of the cube with colormix of r & g
push();
translate(x, y);
noFill();
rotate(radians(30));
stroke(2);
fill(r, g, 0);
quad(0, 0, s, 0, s/2, s*sqrt(3)/2,
-s/2, s*sqrt(3)/2) ;
pop();
// second face of the cube with colormix of g & b
push();
translate(x, y);
rotate(radians(30 + 120));
stroke(2);
fill(0, g, b);
quad(0, 0, s, 0, s/2, s*sqrt(3)/2,
-s/2, s*sqrt(3)/2) ;
pop()
// third face of the cube with colormix of r & b
push();
translate(x, y);
rotate(radians(30 + 120 + 120));
stroke(2);
fill(r, 0, b);
quad(0, 0, s, 0, s/2, s*sqrt(3)/2,
-s/2, s*sqrt(3)/2) ;
pop()
}