xxxxxxxxxx
const COL = createCols("https://coolors.co/bac1b8-58a4b0-0c7c59-2b303a-d64933");
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSB, 360, 100, 100, 100);
frameRate(3);
background('#fff');
for (let j = 0; j < 40; j++) {
for (let i = 0; i < 40; i++) {
let x = i * 40;
let y = j * 40;
stroke(343, 12, 23);
rect(x, y, 40, 40, 3.5, 50,10,30);
}
}
noLoop();
}
// the parameter at which x and y depends is usually taken as either t or symbol of theta
let t = 0;
function draw() {
background(2, 67, 94, 40);
translate(width * 0.33, height * 0.52);
// stroke(0,0,0,50);
// strokeWeight(3);
//loop for adding 100 lines
for (let i = 0; i < 100; i++) {
stroke(COL[int(random(COL.length))]);
strokeWeight(15);
// arc(x1(t + i) - 100, y1(t + i) + 50, -x2(t + i) + 10, -y2(t + i) + 10, x2(t + i) + 10, -y2(t + i) + 10,PIE);
point(x1(t + i) - 30, y1(t + i) + 10);
point(-x2(t + i) + 30, -y2(t + i) + 10, 5);
// translate(width/2, height/2);
stroke(163, 8, 85, 30);
line(x1(t + i) - 10, y1(t + i) + 10, -x2(t + i) + 3, -y2(t + i) + 10);
}
t += 0.15;
}
// function to change initial x co-ordinate of the line
function x1(t) {
return sin(t / 20) * 125 + sin(t / 20) * 125 + sin(t / 40) * 325;
}
// function to change initial y co-ordinate of the line
function y1(t) {
return cos(t / 20) * 125 + cos(t / 10) * 125 + cos(t / 30) * 125;
}
// function to change final x co-ordinate of the line
function x2(t) {
return sin(t / 15) * 125 + sin(t / 15) * 125 + sin(t / 35) * 325;
}
// function to change final y co-ordinate of the line
function y2(t) {
return cos(t / 15) * 125 + cos(t / 5) * 125 + cos(t / 25) * 125;
}
function createCols(_url) {
let slash_index = _url.lastIndexOf('/');
let pallate_str = _url.slice(slash_index + 1);
let arr = pallate_str.split('-');
for (let i = 0; i < arr.length; i++) {
arr[i] = '#' + arr[i];
}
return arr;
}
//keyboardのどこかを押すと画像が保存できるCode
// function keyPressed(){save('pix.jpg'); }