float x1 = 100.0;
float x2 = 225.0;
float x3 = 100.0;
textObject move;
boolean show = false;
int startTime = 0;
PFont times;
int destX;
boolean marked = false;
int spot = 0;
int scroll = 0;
int r1, r2, r3 = 100;
void setup()
{
size(600,300);
angleMode(DEGREES);
noStroke();
times = loadFont("Times.vlw");
fill(79, 195, 255);
framerate(20);
move = new textObject("void moveCircle();", 50, random(width), random(height));
}
void draw()
{
background(255);
textFont(times, 20);
moveCircle();
if(mousePressed==true)
{
if(overCircle(x1, 65, 50)==true)
{
r1= r1*2;
marked = true;
}
if(overCircle(x1+125, 150, 50)==true)
{
r2= r2*2;
marked = true;
}
if(overCircle(x1, 225, 50)==true)
{
r3= r3*2;
marked = true;
}
}
eligible("void mousePressed()", 75);
eligible("destX = mouseX;", 75);
if(marked == true)
{
eligible("r1= r1*2;", 75);
eligible("if(overCircle(x1, 225, 50)==true)", 100);
marked = false;
println(marked);
}
}
void drawRect()
{
fill(204, 100);
rect(0,0, width, height);
}
void mousePressed() {
destX = mouseX;
show = true;
startTime = millis();
}
void mouseReleased() {
r1=100;
r2=100;
r3 = 100;
}
void moveCircle()
{
//if(mousePressed)
// {
drawText("void moveCircle()");
x1=smoother(x1,destX,6);
drawText("x1 = smoother(x1, destX, 6)");
//x2=smoother(x2,destX+125,6);
//x3=smoother(x3,destX,6);
//}
ellipse(x1, 65, r1, r1);
drawText("ellipse(x1, 65, r, r");
ellipse(x1 + 125, 150, r2, r2);
drawText("ellipse(x1 + 125, 150, r, r");
ellipse(x1, 225, r3, r3);
drawText("ellipse(x1, 225, r, r");
}
void eligible(String s, int y){
if (show && millis() - startTime <= 1200) {
drawDoubleText(s, y);
} else {
show = false;
}
}
float smoother(float position, float destination, float speed)
{
float dif = destination - position;
if(abs(dif) > 1.0) {
position = position + dif/speed;
}
return position;
}
int counter()
{
return millis();
}
void drawText(String s)
{
// for(int scroll = 0; scroll<height; scroll+=10)
//{
fill(79, 195, 255);
text(s,random(width), random(height));
//scroll += 60;
//if(scroll>height+100)
// {scroll = 0;
//}
//}
}
void drawDoubleText(String s, int y)
{
fill(0);
textFont(times, y);
text(s, 0, random(height));
}
boolean overCircle(float x, float y, float radius)
{
if(dist(mouseX, mouseY, x, y) < radius) {
return true;
} else {
return false;
}
}
//the code below does not work
void specialText(textObject t)
{
if(t.age < t.lifespan) {
t.render();
}
/*textFont(times, 50);
int p = millis();
while( p < p +10000;)
{
text(s, 200, 75);
}*/
}
class textObject{
int lifespan;
String textmsg;
float x, y;
int age;
textObject(String s, int life, float xi, float yi){
age=0;
lifespan=life;
x = xi;
y = yi;
textmsg = s;
}
void render() {
text(textmsg, x, y);
age++;
}
}