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
   Programs
(Moderators: fry, REAS)
   Re: Round in circles
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Re: Round in circles  (Read 1599 times)
kurol


Re: Round in circles
« on: Mar 29th, 2005, 12:00pm »

LOOKIE WHAT I MADE, MOMMY!!!

 
I'm not quite sure what your intention is, because you said, "I'm trying to get a line draw working within the confines of a circle," and the example code kind of usually sticks to the outside. But here's one thing:
 
Code:
if (sqrt(sq(width/2-xl) + sq(height/2 - yl)) > cDia/2) {

can be replaced by
Code:
if (dist(width/2,height/2,xl,yl) > cDia/2) {
 

I hate programming . . .
Mark Hill

WWW Email
Re: Round in circles
« Reply #1 on: Mar 29th, 2005, 12:15pm »

Thanks for the input.
 
I know what the code produces, which is I why I posted the question in the first place.
 
I'm interested in registering an influence of the confining shape upon the line being drawn.
 
Restricting the drawing to within the confines of a circle is achieved thus:
 
Code:

   xl = mouseX-width/2;
   yl = mouseY-height/2;
   
   i = atan2(mouseY-height/2, mouseX-width/2);
   
   if (dist(0,0,xl,yl) > r) { // yep, it works!
   xl = r * cos(i);  
   yl = r * sin(i);
   }
 

 
Mark Hill

WWW Email
Round in circles
« Reply #2 on: Mar 29th, 2005, 12:22pm »

Deleted original post instead of modify, sorry.
« Last Edit: Mar 29th, 2005, 12:22pm by Mark Hill »  
Pages: 1 

« Previous topic | Next topic »