Processing Forum
float a;
float b;
float theta;
float r;
boolean square = true;
void setup()
{
size(400, 400);
background(255);
smooth();
startNewDrawing();
generateRandomColor();
}
void draw()
{
float x;
float y;
//Convert formula
r = sin (a * theta) + cos (b * theta);
x = r * cos(theta);
y = r * sin(theta);
//Muliply to lengthen lines
x = x * 75;
y = y * 75;
//Things to draw
if (square)
{
pushMatrix();
translate(200 , 200);
rotate(theta);
triangle(x, y - 5, x - 5, y + 5, x + 5, y + 5);
theta = theta + PI/60.0;
popMatrix();
}
else
{
pushMatrix();
translate(200, 200);
rotate( theta);
rect(x, y, 10, 10);
theta = theta + PI/60.0;
popMatrix();
}
}
void mousePressed()
{
startNewDrawing();
}
void startNewDrawing()
{
background(255);
theta = 0;
a = int(random(0, 21))/4.0;
b = int(random(0, 16))/3.0;
}
//cant figure out how to make this part show up in the draw
color generateRandomColor()
{
//color result;
color result = color(random(0, 255), random(0, 255), random(0, 255),
random(192, 255));
return result;
}
void keyPressed()
{
if(key == 's' || key == 't')
{
square = !square;
startNewDrawing();
}
}
Thanks comments, help, anything appreciated.int x = 0;
int y = 0;
int w;
int h;
color c;
int gxSpeed = 1;
int gySpeed = 1;
void setup()
{
size(300, 300);
smooth();
background(255);
}
void draw()
{
drawBalloon(x ,y , w, h, c);
x += gxSpeed;
}
void drawBalloon(int x, int y, int w, int h, color c)
{
fill(c);
ellipse( x , y, w, h);
line(x, y + h /2.0, x + w/ 3.0, y + h/2.0 + h/3.0);
x = int(random(w/2, w - w/2));
y = int(random(h/2, h - h/2));
}