Spinning Dots
Posted on Dec 20th, 2007
tags:
processing
This is my first attempt at a simple project in processing. Overall I think the language is pretty nice since it simplifies many of the concepts associated with graphics programming in Java, like animations (via frames), accelerate graphics, bezier curves (and others), etc.
Roll over the applet to adjust the size of the circles (they are proportional to the distance of the mouse pointer to the center of the applet).
The Code
Plain text
/**
* Kushaura.com - Spinning Dots Source
*/
float x1 = 0;
float y1 = 0;
int i = 1;
float size=60;
float maxSize=120;
float spinner = 1;
float spinIncr = 0.7;
int maxOut = 180;
void setup()
{
size(400, 400);
smooth();
}
void draw()
{
x1 = sin(i) * spinner;
y1 = cos(i) * -spinner;
i++;
spinner+=spinIncr;
if(spinner < 0 || spinner > maxOut)
{
spinIncr = -spinIncr;
}
fill(0, 12);
rect(0, 0, width, height);
fill(255);
noStroke();
ellipse(x1+200, y1+200, size, size);
size = maxSize * dist(mouseX,mouseY,width/2,height/2) / width;
}