xxxxxxxxxx
64
function setup() {
createCanvas(400, 400);
rectMode(CENTER);
noFill();
stroke("#5C2FC2");
strokeWeight(10);
}
function draw() {
background(220);
translate(width/2,height/2);
const s = 300;
rect(0,0,s,s);
triangle_edge(s);
push();
scale(1,-1);
triangle_edge(s);
pop();
push();
scale(-1,-1);
triangle_edge(s);
pop();
push();
scale(-1,1);
triangle_edge(s);
pop();
// 以降十字架
rect(0,-60,30,100);
push();
rotate(PI/2);
rect(0,-60,30,100);
pop();
push();
rotate(-PI/2);
rect(0,-60,30,100);
pop();
push();
scale(-1,-1);
rect(0,-60,30,100);
pop();
noLoop();
}
const triangle_edge = (s) => {
// 2つ目の三角
const x1 = -s/2;
const y1 = -s/2;
const x2 = x1 + s/6;
const y2 = y1;
const x3 = x1;
const y3 = y1 + s/6;
triangle(x1,y1,x2,y2,x3,y3);
};