Skip to content

Instantly share code, notes, and snippets.

@ryuchan00
Created May 23, 2020 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryuchan00/776ee1caad9f81afda4fbc6781de9d94 to your computer and use it in GitHub Desktop.
Save ryuchan00/776ee1caad9f81afda4fbc6781de9d94 to your computer and use it in GitHub Desktop.
シンガポール🇸🇬みたいな円状に均等に星を配置するやつ
// 🇸🇬
size(120, 120);
background(255);
noStroke();
fill(152, 251, 152);
int a[] = {1,4,2,5,3};
int b;
float x;
float y;
float center_x;
float center_y;
for (int i = 0; i < 5; i++) {
center_x = 50 * cos(2 * PI * i / 5 + PI / 2) + 60;
center_y = 50 * sin(2 * PI * i / 5 - PI / 2) + 60;
beginShape();
for (int j = 0; j < 5; j++) {
b = a[j] - 1;
x = 10 * cos(2 * PI * b / 5 + PI / 2) + center_x;
y = 10 * sin(2 * PI * b / 5 - PI / 2) + center_y;
vertex(x, y);
}
endShape();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment