Created
October 12, 2019 08:45
-
-
Save YuzuruSano/7d47734dc0a56b83e90d7f4d324e510f to your computer and use it in GitHub Desktop.
p5js-タイル状に色を配置
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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