Skip to content

Instantly share code, notes, and snippets.

@sasaki-shigeo

sasaki-shigeo/stars.pde

Last active Dec 30, 2015
Embed
What would you like to do?
Drawing stars / Processing で星形(5芒星)を描く
void setup() {
size(500, 500);
noStroke();
fill(255, 255, 0);
for (int i = 0; i < 10; i++) {
star(random(width), random(height), 30);
}
}
void star(float x, float y, float r) {
pushMatrix();
translate(x, y);
scale(1, -1);
rotate(HALF_PI);
beginShape();
for (int i = 0; i < 5; i++) {
vertex(r * cos(4 * PI * i / 5), r * sin(4 * PI * i / 5));
}
endShape(CLOSE);
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.