We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › translate, rotate - a newbie question
Page Index Toggle Pages: 1
translate, rotate - a newbie question (Read 409 times)
translate, rotate - a newbie question
May 8th, 2008, 6:29pm
 
i am reading casey and ben fry's book... they mentioned that transformation (translate, rotate, scale) will be accumulated at run time...

if i want to rotate the stage a bit more in the void draw(){}, is that possible


// for instance, here's what i want to archieve
// a for loop approach, it worked
void setup() {
 size(500,500,P3D);
 background(0);
 stroke(255);
 translate(250,250);
 for(int i=0;i<1000;i++) {
   rotate(0.1);
    point(i/10,i/10);
 }
}

// desired approach
// but i want it to do bit by bit so i can see how it happens
// but it failed this way... seems like transformation is not accumulated ~
int i;
void setup() {
 size(500,500,P3D);
 background(0);
 stroke(255);
  translate(250,250);
  i=0;
}
void draw() {
 rotate(0.1);
 point(i,i);
 i++;
}

thanks in advanced Smiley
kitDS
Re: translate, rotate - a newbie question
Reply #1 - May 8th, 2008, 6:57pm
 
Unfortunately it doesn't build up over subsequent draw() runs, everything is reset between frames.

You can get the effect you want with:

Code:
int i;
float angle;
void setup() {
size(500,500,P3D);
background(0);
stroke(255);
i=0;
angle=0.1;
}
void draw() {
translate(250,250); //this also needs to happen every frame.
rotate(angle);
point(i,i);
angle=angle+0.1;
i++;
}
Re: translate, rotate - a newbie question
Reply #2 - May 8th, 2008, 6:59pm
 
thanks JohnG Cheesy
Page Index Toggle Pages: 1