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 & HelpSyntax Questions › drawing lines (beginner)
Page Index Toggle Pages: 1
drawing lines (beginner) (Read 1079 times)
drawing lines (beginner)
Nov 9th, 2009, 5:32pm
 
I'm trying to draw a line to a pre-determined location. I mean this in the sense that the line is actively drawn (animated) on screen to specific coordinates.
So that with the playing of the program, a line is drawn from the center of the screen to the specific coordinates.
I hope that makes sense.
Re: drawing lines (beginner)
Reply #1 - Nov 9th, 2009, 8:41pm
 
Can you try this in your draw()?
background(128);
line(width/2,height/2, location_x, location_y);

This draws a line from the center of the screen to your specified location location_x, location_y. Each time you run draw(), update this location.
Re: drawing lines (beginner)
Reply #2 - Nov 10th, 2009, 2:20am
 
You can use lerp() to interpolate positions between the center of the screen and the chosen destination. Increment the lerp's amt parameter by a small value (depending on speed you want to attain) on each draw() call until it reaches 1.0.
Re: drawing lines (beginner)
Reply #3 - Nov 10th, 2009, 3:44pm
 
Sorry if i didn't express my question very well, an example of what i was looking for was something along the lines of the following (probably not the most efficient way of doing it):

   stroke(255);
   strokeWeight(6);
   line(400, 300, i, 700-i);
   if ( i < 600 )
   {
      i = i + 3;
     
      if(i >= 600)
      {
        noLoop();
      }      
   }
Re: drawing lines (beginner)
Reply #4 - Nov 11th, 2009, 1:37am
 
You will never reach noLoop() in your code... Smiley
And I think my answer is still valid.
Page Index Toggle Pages: 1