Last active
November 7, 2016 14:01
-
-
Save Etclsc/11e4342d86d4f6a74011b2d8c6087d5d to your computer and use it in GitHub Desktop.
色つき円を表示するサンプルコード
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
int N = 30; // 円の個数 | |
int dist = 200; // 大円の半径 | |
int hue_step = 360 / N; | |
int wh = 30; | |
size(500, 500); | |
int[] hsbMax = {360, 255, 255}; | |
colorMode(HSB, hsbMax[0], hsbMax[1], hsbMax[2]); | |
background(360); | |
noStroke(); | |
translate(width / 2, height / 2); | |
for(int i = 0; i < N; i++) | |
{ | |
int x = (int)(dist*cos(2*PI*i/N - PI/2)); | |
int y = (int)(dist*sin(2*PI*i/N - PI/2)); | |
fill(i * hue_step, hsbMax[1], hsbMax[2]); | |
ellipse(x, y, wh, wh); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment