Last active
June 8, 2024 03:56
-
-
Save n1ckfg/2cd460233402df13fd0a01865afc5a8b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
licensed with CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0 | |
Nick Fox-Gieg / @n1ckfg / fox-gieg.com | |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
p = new P5({width: 500, height: 500, mode: 'WEBGL'}) // loads p5js library, comment this line after using it once | |
p.hide() // hide p5js canvas. | |
polylines = [] | |
clicked = false | |
p.stroke(255) | |
p.strokeWeight(4) | |
p.noFill() | |
p.mousePressed = () => { | |
clicked = true; | |
polylines.push([]) | |
} | |
p.mouseReleased = () => { | |
clicked = false | |
} | |
p.keyPressed = () => { | |
polylines = [] | |
} | |
p.draw = () => { | |
p.background(0); | |
if (clicked) { | |
polylines[polylines.length-1].push(p.createVector(p.mouseX, p.mouseY)); | |
} | |
for (let i=0; i<polylines.length; i++) { | |
p.beginShape(); | |
for (let j=0; j<polylines[i].length; j++) { | |
let co = polylines[i][j]; | |
p.vertex(co.x - p.width/2, co.y - p.height/2); | |
} | |
p.endShape(); | |
} | |
} | |
s0.init({src: p.canvas}) | |
src(s0).out() | |
//src(s0).repeat(4, 4).scroll(0.1,-0.3,0.05,0.05).out() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment