Created
March 4, 2021 09:26
-
-
Save taruscript/188975b99d6658fd89b1bc9d53f58b9d to your computer and use it in GitHub Desktop.
マウスカーソルを動かすと幾何学が生成されるアート
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
let symmetry = 10; | |
let angle = 360 / symmetry; | |
let saveButton; | |
let clearButton; | |
let slider; | |
let xoff = 0; | |
function setup() { | |
createCanvas(1920, 1080); | |
angleMode(DEGREES); | |
} | |
function draw() { | |
translate(width / 2, height / 2); | |
if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { | |
let mx = mouseX - width / 2; | |
let my = mouseY - height / 2; | |
let pmx = pmouseX - width / 2; | |
let pmy = pmouseY - height / 2; | |
let hu = map(sin(xoff), -1,1,0,255); | |
xoff += 1; | |
// stroke(hu, 100); | |
let angle = 360 / symmetry; | |
for (let i = 0; i < symmetry; i++) { | |
rotate(angle); | |
let d = dist(mx, my, pmx, pmy); | |
let sw = map(d, 0, 0, 0, 0); | |
strokeWeight(sw); | |
stroke(random(0, 255)) | |
line(mx, my, pmx, pmy); | |
push(); | |
scale(1, -1); | |
line(mx, my, pmx, pmy); | |
pop(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment