PR0C3551N6 ではじめるアメーバ(カラー版)

PR0C3551N6 のテスト

PR0C3551N6 のテスト

final int MAX_POINT = 180;
final int RADIUS = 150;
final int POINT_SIZE = 5;
PVector[] point = new PVector[MAX_POINT];

float halfWidth;
float halfHeight;

void setup(){
    //size(400, 400);
    halfWidth = width / 2;
    halfHeight = height / 2;
    colorMode(HSB);
    smooth();
    noStroke();
    
    //  各ポイントにベクトルをセット
    for(int i = 0; i < MAX_POINT; i++){
        float d = 360.0 / MAX_POINT * i;
        float x = cos(radians(d)) * RADIUS;
        float y = sin(radians(d)) * RADIUS;
        point[i] = new PVector(x, y);
    }
    
}

int c = 0;
void draw(){
    background(0);
    c += 5;
    
    PVector tmp = new PVector();
    PVector center = new PVector(halfWidth, halfHeight);
    
    //  各点を描く
    for(int i = 0; i < MAX_POINT; i++){
        tmp.set(point[i]);
        tmp.mult((sin(radians(i * 14 + c * 1.2))) * 0.2 + 0.8);
        tmp.mult((cos(radians(i * 18 + -c * 1.7))) * 0.2 + 0.8);
        tmp.add(center);
        fill(map(i,0,180,0,255),255,255);
        ellipse(tmp.x, tmp.y, POINT_SIZE, POINT_SIZE);
    }
}