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.
Page Index Toggle Pages: 1
Drawing a loop (Read 801 times)
Drawing a loop
Mar 20th, 2007, 9:09pm
 
Just a quick question to see if it's possible but I want to create a interactive graphic program where you can hold down the mouse in one spot and it draws a loop - is it possible?
Re: Drawing a loop
Reply #1 - Mar 21st, 2007, 6:31am
 
sure.
Re: Drawing a loop
Reply #2 - Mar 26th, 2007, 10:27am
 
How?

Rather than it just appearing I want it so that the program shows it drawing!

Thanks for any help
Re: Drawing a loop
Reply #3 - Mar 26th, 2007, 10:54am
 
drawing a piece of a circle:
Code:


float[] xcircle;
float[] ycircle;

void setup ()
{
size( 200, 200 );
int circlesteps = 6;
xcircle = new float[360/circlesteps];
ycircle = new float[360/circlesteps];

for ( int i = 0; i<xcircle.length; i++ )
{
xcircle[i] = sin(radians(i*circlesteps));
ycircle[i] = cos(radians(i*circlesteps));
}
}

int percCounter = 1;

void draw()
{
background(125);
translate(width/2, height/2);

drawLoop(50,percCounter);
percCounter++;
percCounter %= 101;
}

void drawLoop (float rad, float perc)
{
int steps = floor((xcircle.length/100.0) * perc);
beginShape();
for( int i=0; i<steps; i++ )
{
vertex(rad*xcircle[i],rad*ycircle[i]);
}
endShape(CLOSE);
}


now you all you need to do is add code for the clicking:
http://processing.org/reference/mouseReleased_.html

and keep track of which circles are where and at how many percent they are.

F
Re: Drawing a loop
Reply #4 - Mar 26th, 2007, 4:46pm
 
Cool - Thank you
Page Index Toggle Pages: 1