Skip to content

Instantly share code, notes, and snippets.

@amano41
Last active December 21, 2015 01:38
Show Gist options
  • Save amano41/6228703 to your computer and use it in GitHub Desktop.
Save amano41/6228703 to your computer and use it in GitHub Desktop.
ボールが色を変えながら回転するサンプル http://amano41.hateblo.jp/entry/2013/08/14/170508
int fps = 15;
int radius = 50;
int cycle = 5; // 回転周期
int speed = 5; // 拡散速度
int degree = 360 / (cycle * fps);
void setup() {
size(200, 200);
frameRate(fps);
colorMode(HSB, 360, 100, 100);
}
void draw() {
float rad = radians(degree * frameCount);
float x = width/2 + radius * cos(rad);
float y = height/2 + radius * sin(rad);
color c = color(frameCount % 360, 100, 80);
// 波紋の不透明度と大きさの係数
float k = sin(radians(speed * frameCount % 90));
smooth();
noStroke();
background(0, 0, 100);
// 波紋
fill(c, 50-50*k);
ellipse(x, y, width*k, width*k);
// 球体
fill(c);
ellipse(x, y, 20, 20);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment