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)
   Ringpolygon
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Ringpolygon  (Read 410 times)
eskimoblood

222550793222550793 WWW
Ringpolygon
« on: Feb 13th, 2005, 3:51pm »

Is there a way to draw ringpolygons in processing?
 
fry


WWW
Re: Ringpolygon
« Reply #1 on: Feb 13th, 2005, 8:07pm »

what's a ringpolygon?
 
JohnG

WWW
Re: Ringpolygon
« Reply #2 on: Feb 14th, 2005, 12:46pm »

If you mean is there a way to draw rings, then there's no built in way, but the following code shoudl do what you want, I think:
 
Code:

void ringpoly(float radius, float _size, int segments)
{
  float dt=TWO_PI/(float)segments;
  //dt = delta theta, i.e. how wide is each segment, in radians.
  for(int i=0;i<segments;i++)
  {
    beginShape(QUADS);
    {
 //work clockwise around segment, so it looks correct
 vertex(radius*sin(dt*i),radius*cos(dt*i),0);
 vertex(radius*sin(dt*(i+1)),radius*cos(dt*(i+1)),0);
 vertex((radius+_size)*sin(dt*(i+1)),(radius+_size)*cos(dt*(i+1)),0);
 vertex((radius+_size)*sin(dt*i),(radius+_size)*cos(dt*i),0);
    }
    endShape();
  }
}
 
void setup()
{
  size(400,400);
  background(0);
  translate(width/2,height/2);
  ringpoly(150,25,32);
  fill(255,0,0);
  ringpoly(100,25,16);
  fill(0,255,0);
  ringpoly(50,25,4);
}
 
eskimoblood

222550793222550793 WWW
Re: Ringpolygon
« Reply #3 on: Feb 14th, 2005, 4:53pm »

on Feb 13th, 2005, 8:07pm, fry wrote:
what's a ringpolygon

 
 
its a polygon with a hole
 
Pages: 1 

« Previous topic | Next topic »