見出し画像

Daily Coding(p5.js) No.16

おはようございます。

今日から大学が始まったので、少し時間が取りにくくなり進捗は進みづらくなるとは思うのですが、できる限り毎日続けていきたいと思います💪

画像1

画像2

Code

l

et width = 500;
let height = 500;
let widthcount = 17;
let heightcount = 17;
let sqwidth = (width - 100) / widthcount;
let sqheight = (height - 100) / heightcount;
let off = 100;

function setup() {
   createCanvas(width, height);
   noLoop();
   smooth();
   noFill();
   rectMode(CENTER);
}

function draw() {
   background(230,230,230);
   for(let i = 0; i < widthcount; i++) {
       for(let j = 0; j < heightcount; j++) {
           //off = 100 + int(random(-3,3));
           stroke(77, 54, 58, int(random(150,250)));
           Square(off/2 + sqwidth/2 + i * sqwidth, off/2 + sqheight/2 + j * sqheight);
       }
   }
}

function Square(x, y) {
   //四角形を重ねる回数
   let drawcount = int(random(2,10)); 
   let sq = [];
   let r = sqwidth;
   for(let a = 0; a < drawcount; a++) {
       //四角形の幅
       if(r - 6 < 0) break;
       r = int(random(r - 6, r));
       //ellipse(x, y, r*random(0.9,1.1), r*random(0.9,1.1));
       rect(x, y, r, r);
       
   }
}

function keyPressed() {
   if(key == 'r') redraw();
}

半月達成✌️

ではでは

この記事が気に入ったらサポートをしてみませんか?