별 애니

2010. 6. 12. 15:09 프로그래밍

void setup() {
	size(200, 200);
	smooth();
}

void star() {
	fill(200, 0, 0, 150);
	noStroke();
	beginShape();
	for (int i = 0; i < 10; i++) {
		float a = radians(i * 36);
		float l = i % 2 == 0 ? 10 : 20; 
		vertex(cos(a)*l, sin(a)*l);
	}
	endShape(CLOSE);
}

void draw() {
	float a;
	background(255);
	pushMatrix();
	translate(width / 2, height / 2);
	a = radians(frameCount);
	rotate(a);
	translate(50, 0);
	rotate(-a);
	for (int i = 0; i < 3; i++) {
		//a = radians(frameCount * 4 + i * 120);
		a = radians((2.0 - cos(radians(frameCount* 2 % 180))) * 180 + i * 120);
		pushMatrix();
		rotate(a);
		translate(20, 0);
		rotate(-a + sin(radians(frameCount * 8)) * 0.3);
		scale(1 + sin(a)*0.4, 1 + sin(a)*0.4);
		star();
		popMatrix();
	}
	popMatrix();
}
Posted by dEtH :