Created
March 5, 2020 02:57
-
-
Save Morpholux/f32b71d28d13331e494b6a556bdbd080 to your computer and use it in GitHub Desktop.
Using curveVertex to create a blob type of closed shape
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
// renaud.jean-francois(arobas)uqam(point)ca | |
// Syntaxe Processing version 3.5.4 | |
// mercredi, 4 mars 2020 | |
int numPoints = 7; | |
float[] posX = new float[numPoints]; | |
float[] posY = new float[numPoints]; | |
float radius; | |
float theta = TWO_PI / numPoints; | |
void setup() { | |
size(600, 600); | |
background(0); | |
fill(239, 91, 49); | |
noStroke(); | |
curveTightness(-0.5); | |
noLoop(); | |
} | |
void draw() { | |
background(47, 53, 144); | |
// Create vertex position | |
for (int i = 0; i < posX.length; i++) { | |
if ((i%2) == 0) { | |
radius = 150 + (random(2) * 50); | |
} else { | |
radius = 150 + (random(2) * -50); | |
} | |
posY[i] = sin(theta * i) * radius; | |
posX[i] = cos(theta * i) * radius; | |
} | |
translate(width/2, height/2); | |
beginShape(); | |
curveVertex(posX[posX.length-1], posY[posX.length-1]); | |
for (int i = 0; i < posX.length; i++) { | |
curveVertex(posX[i], posY[i]); | |
} | |
curveVertex(posX[0], posY[0]); | |
curveVertex(posX[1], posY[1]); // additional Curvevertex are use to close the shape | |
endShape(); | |
save("render_"+frameCount+".jpg"); | |
} | |
void mousePressed() { | |
redraw(); | |
} |
Author
Morpholux
commented
Mar 5, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment