xxxxxxxxxx
185
function setup() {
createCanvas(1071 / 12 * 8, 1600 / 24 * 15);
}
function draw() {
let gridWidth = width / 8;
let gridHeight = height / 15;
let cubeHeight = gridHeight * 6;
let colorSepia = '#9A7040';
let colorWhite = '#EDEBDE';
let colorBlue = '#3E5D9D';
let colorRed = '#D53B0D';
background(colorSepia);
noStroke();
//cube1
//side1
fill(colorWhite);
beginShape();
let side1BottomLeft = createVector(gridWidth * 0, gridHeight * 12.4);
let side1BottomRight = createVector(gridWidth * 4, gridHeight * 15);
let side1TopRight = createVector(side1BottomRight.x, side1BottomRight.y - cubeHeight);
let side1TopLeft = createVector(side1BottomLeft.x, side1BottomLeft.y - cubeHeight);
vertex(side1BottomLeft.x, side1BottomLeft.y);
vertex(side1BottomRight.x, side1BottomRight.y);
vertex(side1TopRight.x, side1TopRight.y);
vertex(side1TopLeft.x, side1TopLeft.y);
endShape(CLOSE);
//side2
fill(colorRed);
beginShape();
let side2BottomLeft = side1BottomRight;
let side2BottomRight = createVector(gridWidth * 8, side1BottomLeft.y);
let side2TopRight = createVector(side2BottomRight.x, side2BottomRight.y - cubeHeight);
let side2TopLeft = createVector(side2BottomLeft.x, side2BottomLeft.y - cubeHeight);
vertex(side2BottomLeft.x, side2BottomLeft.y);
vertex(side2BottomRight.x, side2BottomRight.y);
vertex(side2TopRight.x, side2TopRight.y);
vertex(side2TopLeft.x, side2TopLeft.y);
endShape(CLOSE);
//side3
fill(colorBlue);
beginShape();
let side3Left = side1TopLeft;
let side3Bottom = side1TopRight;
let side3Right = side2TopRight;
let side3Top = createVector(gridWidth * 4, gridHeight * 3.4);
vertex(side3Left.x, side3Left.y);
vertex(side3Bottom.x, side3Bottom.y);
vertex(side3Right.x, side3Right.y);
vertex(side3Top.x, side3Top.y);
endShape(CLOSE);
//cube2
cubeHeight /= 2;
//side1
fill(colorRed);
beginShape();
side1BottomLeft = side1TopLeft;
side1BottomRight = createVector((side1TopLeft.x + side1TopRight.x) / 2, (side1TopLeft.y + side1TopRight.y) / 2);
side1TopRight = createVector(side1BottomRight.x, side1BottomRight.y - cubeHeight);
side1TopLeft = createVector(side1BottomLeft.x, side1BottomLeft.y - cubeHeight);
vertex(side1BottomLeft.x, side1BottomLeft.y);
vertex(side1BottomRight.x, side1BottomRight.y);
vertex(side1TopRight.x, side1TopRight.y);
vertex(side1TopLeft.x, side1TopLeft.y);
endShape(CLOSE);
//side2
fill(colorWhite);
beginShape();
side2BottomLeft = side1BottomRight;
side2BottomRight = createVector(gridWidth * 4, side1BottomLeft.y);
side2TopRight = createVector(side2BottomRight.x, side2BottomRight.y - cubeHeight);
side2TopLeft = createVector(side2BottomLeft.x, side2BottomLeft.y - cubeHeight);
vertex(side2BottomLeft.x, side2BottomLeft.y);
vertex(side2BottomRight.x, side2BottomRight.y);
vertex(side2TopRight.x, side2TopRight.y);
vertex(side2TopLeft.x, side2TopLeft.y);
endShape(CLOSE);
//side3
fill(colorBlue);
beginShape();
side3Left = side1TopLeft;
side3Bottom = side1TopRight;
side3Right = side2TopRight;
side3Top = createVector(gridWidth * 2, gridHeight * 2);
vertex(side3Left.x, side3Left.y);
vertex(side3Bottom.x, side3Bottom.y);
vertex(side3Right.x, side3Right.y);
vertex(side3Top.x, side3Top.y);
endShape(CLOSE);
//cube3
cubeHeight /= 2;
//side1
fill(colorWhite);
beginShape();
side1BottomLeft = createVector((side3Left.x + side3Top.x) / 2, (side3Left.y + side3Top.y) / 2);
side1BottomRight = createVector(gridWidth * 2, gridHeight * 3.4);
side1TopRight = createVector(side1BottomRight.x, side1BottomRight.y - cubeHeight);
side1TopLeft = createVector(side1BottomLeft.x, side1BottomLeft.y - cubeHeight);
vertex(side1BottomLeft.x, side1BottomLeft.y);
vertex(side1BottomRight.x, side1BottomRight.y);
vertex(side1TopRight.x, side1TopRight.y);
vertex(side1TopLeft.x, side1TopLeft.y);
endShape(CLOSE);
//side2
fill(colorRed);
beginShape();
side2BottomLeft = side1BottomRight;
side2BottomRight = createVector(gridWidth * 3, side1BottomLeft.y);
side2TopRight = createVector(side2BottomRight.x, side2BottomRight.y - cubeHeight);
side2TopLeft = createVector(side2BottomLeft.x, side2BottomLeft.y - cubeHeight);
vertex(side2BottomLeft.x, side2BottomLeft.y);
vertex(side2BottomRight.x, side2BottomRight.y);
vertex(side2TopRight.x, side2TopRight.y);
vertex(side2TopLeft.x, side2TopLeft.y);
endShape(CLOSE);
//side3
fill(colorBlue);
beginShape();
side3Left = side1TopLeft;
side3Bottom = side1TopRight;
side3Right = side2TopRight;
side3Top = createVector(gridWidth * 2, gridHeight * 0.5);
vertex(side3Left.x, side3Left.y);
vertex(side3Bottom.x, side3Bottom.y);
vertex(side3Right.x, side3Right.y);
vertex(side3Top.x, side3Top.y);
endShape(CLOSE);
//cube4
cubeHeight /= 2;
//side1
fill(colorRed);
beginShape();
side1BottomLeft = createVector(gridWidth * 2, side3Top.y + cubeHeight);
side1BottomRight = createVector((side2TopLeft.x + side2TopRight.x) / 2, (side2TopLeft.y + side2TopRight.y) / 2);
side1TopRight = createVector(side1BottomRight.x, side1BottomRight.y - cubeHeight);
side1TopLeft = createVector(side1BottomLeft.x, side1BottomLeft.y - cubeHeight);
vertex(side1BottomLeft.x, side1BottomLeft.y);
vertex(side1BottomRight.x, side1BottomRight.y);
vertex(side1TopRight.x, side1TopRight.y);
vertex(side1TopLeft.x, side1TopLeft.y);
endShape(CLOSE);
//side2
fill(colorWhite);
beginShape();
side2BottomLeft = side1BottomRight;
side2BottomRight = createVector(gridWidth * 3, side1BottomLeft.y);
side2TopRight = createVector(side2BottomRight.x, side2BottomRight.y - cubeHeight);
side2TopLeft = createVector(side2BottomLeft.x, side2BottomLeft.y - cubeHeight);
vertex(side2BottomLeft.x, side2BottomLeft.y);
vertex(side2BottomRight.x, side2BottomRight.y);
vertex(side2TopRight.x, side2TopRight.y);
vertex(side2TopLeft.x, side2TopLeft.y);
endShape(CLOSE);
//side3
fill(colorBlue);
beginShape();
side3Left = side1TopLeft;
side3Bottom = side1TopRight;
side3Right = side2TopRight;
side3Top = createVector(gridWidth * 2.5, gridHeight * 0.175);
vertex(side3Left.x, side3Left.y);
vertex(side3Bottom.x, side3Bottom.y);
vertex(side3Right.x, side3Right.y);
vertex(side3Top.x, side3Top.y);
endShape(CLOSE);
}