Created
June 19, 2020 14:51
-
-
Save fewlinesofcode/c6a8650c09a68509a642c99dd74abb83 to your computer and use it in GitHub Desktop.
p5 Pillow drawing
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
const s = (p) => { | |
const w = 400; | |
const h = 400; | |
// Center coordinates | |
const x0 = 200; | |
const y0 = 200; | |
// Radius | |
const r = 150; | |
var angle = 0; | |
p.setup = () => { | |
p.createCanvas(w, h); | |
p.stroke(0, 0, 0, 10); | |
p.background(225); | |
}; | |
p.draw = () => { | |
var a, b = 0; | |
var numPoints = 10; | |
for(var i = 0; i <= numPoints; i++) { | |
// Pillow | |
var x = x0 + r * Math.cos(2 * Math.PI * i / numPoints - angle); | |
var y = y0 + r * Math.sin(2 * Math.PI * i / numPoints + angle); | |
if (i != 0) p.line(a, b, x, y); | |
a = x; | |
b = y; | |
} | |
angle += 1; | |
}; | |
}; | |
let myp5 = new p5(s); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment