xxxxxxxxxx
122
let coswave = [];
function setup() {
createCanvas(400, 400);
for (let i = 0; i < width; i++) {
let amount = map(i, 0, width, 0, PI);
coswave[i] = abs(cos(amount));
}
noLoop();
}
function draw() {
background(255);
push();
fill(0);
rectMode(CENTER);
// noStroke();
// translate(width / 2, height / 2);
rect(200, 100, 440, 600);
pop();
let y3 = 0;
let y4 = height ;
push();
for (let i = 0; i < width; i += 10) {
stroke(255);
strokeWeight(3);
line(i, y3, i, y4);
// translate(1,0);
}
pop();
push();
rectMode(CENTER);
// noStroke();
strokeWeight(5);
translate(width / 2, height / 2);
rotate(2.35);
noStroke();
rect(0, 0, 250, 250);
pop();
push();
fill(0);
triangle(22, 200, 80, 255, 80, 145);
pop();
push();
fill(0);
triangle(378, 200, 320, 255, 320, 145);
pop();
// push();
for (let i = 0; i < width; i += 4) {
stroke(255);
strokeWeight(4);
// line(i+2, y3, i+2, y4);
// translate(1,0);
}
let y1 = 0;
let y2 = height/100 ;
y1 = y2;
y2 = height;
for (let i = 0; i < width; i +=10) {
push();
// stroke(255 - coswave[i] * 255);
stroke(0);
strokeWeight(5*coswave[i]);
line(i+3, y1+3, i+3, y2+3);
// stroke(255);
// strokeWeight(4*sinwave[i])
// line(i-i, y1, i-i, y2);
pop();
}
for (let i = 0; i < width; i += 10) {
stroke(255);
strokeWeight(3);
line(i, y3, i, y4);
// translate(1,0);
}
// pop();
}
// function draw() {
// let y1 = 0;
// let y2 = height / 3;
// for (let i = 0; i < width; i += 3) {
// stroke(coswave[i] * 255);
// line(i, y1, i, y2);
// }
// y1 = y2;
// y2 = y1 + y1;
// for (let i = 0; i < width; i += 3) {
// stroke((coswave[i] * 255) / 4);
// line(i, y1, i, y2);
// }
// y1 = y2;
// y2 = height;
// for (let i = 0; i < width; i += 3) {
// stroke(255 - coswave[i] * 255);
// line(i, y1, i, y2);
// }
// }