FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   can' t make the circle smaller
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: can' t make the circle smaller  (Read 238 times)
kemo

Email
can' t make the circle smaller
« on: Sep 23rd, 2003, 4:28pm »

If i run this code the circle will increase in size, but it won' t decrease in size. But if you look in the println box you'll see that it decreases.
 
Can somebody help me.
 
void setup()  
 
{
 size(400,400);
 background(304,102,67);
 noStroke();
 ellipseMode(CENTER_DIAMETER);
}
 
boolean circle_big = false;
boolean groei = true;
float a=1.0;
int x;
int y;
 
void loop() {
x=width/2;
y=height/2;
 
 
if(groei == true){
  a=a*1.02;
  ellipse(x,y,a,a);
 
  if(a>300) {
    groei = false;
  }
}
else
{
  a=a*0.98;
   
  ellipse(x,y,a,a);
  print(" a = " + a);
}
}
 
mKoser

WWW Email
Re: can' t make the circle smaller
« Reply #1 on: Sep 23rd, 2003, 4:59pm »

what version are you using?
 
i just tested your code on 0058 and 0059 and they both work just fine... BUT ...in case you are using 0060, you have hit some of the API changes!
 
in the latest release (0060) background has changed. Before it set the background color - but now, you have to call it manually every time you wish for your drawing to be erased/refreshed... The reason you didn't see the circle growing smaller was that you were drawing smaller white circle on top of larger white circles... it did happen, you just couldn't see it.
 
i've added a call to background(304,102,67) in the beginning of every loop to enable refreshing of your canvas!
 
Code:

void setup(){
  size(400,400);
  background(304,102,67);
  noStroke();
  ellipseMode(CENTER_DIAMETER);
}
 
boolean circle_big = false;
boolean groei = true;
float a = 1.0;
int x;
int y;
 
void loop() {
  background(304,102,67);    // this line was added
  x=width/2;
  y=height/2;
 
  if(groei == true){
    a=a*1.02;
    ellipse(x,y,a,a);
 
    if(a>300) {
 groei = false;
    }
  }
  else
  {
    a=a*0.98;
 
    ellipse(x,y,a,a);
  }
}

 
more reference on this:
http://www.proce55ing.net/reference/background_.html
 
+ mikkel
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
kemo

Email
Re: can' t make the circle smaller
« Reply #2 on: Sep 23rd, 2003, 7:15pm »

I am using version 6.0.
 
Thanks for your help.. i'm gonna check the reference
« Last Edit: Sep 23rd, 2003, 7:23pm by kemo »  
Pages: 1 

« Previous topic | Next topic »