Skip to content

Instantly share code, notes, and snippets.

@YuzuruSano
Created October 12, 2019 08:45
Show Gist options
  • Save YuzuruSano/7d47734dc0a56b83e90d7f4d324e510f to your computer and use it in GitHub Desktop.
Save YuzuruSano/7d47734dc0a56b83e90d7f4d324e510f to your computer and use it in GitHub Desktop.
p5js-タイル状に色を配置
import * as p5 from 'p5';
let s = (sk) => {
let stepX;
let stepY;
sk.setup = () => {
sk.createCanvas(800, 400);
sk.noStroke();
sk.colorMode(sk.HSB, sk.width, sk.height, 100);
}
sk.draw = () => {
stepX = sk.pmouseX + 2;
stepY = sk.pmouseY + 2;
for(let gridY = 0; gridY < sk.height; gridY += stepY){
for (let gridX = 0; gridX < sk.width; gridX += stepX) {
sk.fill(gridX, sk.height - gridY, 60);
sk.rect(gridX, gridY, stepX, stepY);
}
}
}
}
const P5 = new p5(s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment