Daily Coding(p5.js) No.20
ステンドガラス感がありますね
Code
let off = 50;
let w = 460/2;
let h = 460/2;
let wid = 460/9;
function setup() {
createCanvas(460, 460);
noLoop();
}
function draw() {
background(230);
for(let i = 0; i < 25; i++) {
Line(wid*int(random(1,7)),wid*int(random(1,7)));
}
stroke(0);
for(let i = 0; i < 8; i++) {
Squx(i * 50);
Squy(i * 50);
}
noFill();
for(let i = 0; i < 30; i++) {
quad(w+random(-25,25), h+random(-25,25), w+random(-25,25), h+random(-25,25),
w+random(-25,25), h+random(-25,25), w+random(-25,25), h+random(-25,25));
}
}
function Squx(y) {
for(let i = 0; i < 9; i++) {
let start = i * 40;
let goal = (i+1) * 40;
for(let j = 0; j < 12; j++) {
line(start+ off, y + random(0,15) + off, goal + off, y + random(0,15) + off );
}
}
}
function Squy(x) {
for(let i = 0; i < 9; i++) {
let start = i * 40;
let goal = (i+1) * 40;
for(let j = 0; j < 12; j++) {
line(x + random(0,10) + off, start + off, x + random(0,10) + off, goal + off);
}
}
}
function Line(x, y) {
let r = random(1);
stroke(int(random(255)),int(random(255)),int(random(255)));
if(r < 0.5) {
for(let i = 0; i < 30; i++){
let a = random(wid-5);
line(x+3, y+a+5, x+wid-3, y+a+5);
}
} else {
for(let i = 0; i < 30; i++){
let a = random(wid);
line(x+a, y+5, x+a, y+wid+5);
}
}
}
function keyPressed() {
if(key == 'r') redraw();
}
では👏
この記事が気に入ったらサポートをしてみませんか?