|
Author |
Topic: Ringpolygon (Read 410 times) |
|
eskimoblood
|
Ringpolygon
« on: Feb 13th, 2005, 3:51pm » |
|
Is there a way to draw ringpolygons in processing?
|
|
|
|
fry
|
Re: Ringpolygon
« Reply #1 on: Feb 13th, 2005, 8:07pm » |
|
what's a ringpolygon?
|
|
|
|
JohnG
|
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
|
Re: Ringpolygon
« Reply #3 on: Feb 14th, 2005, 4:53pm » |
|
on Feb 13th, 2005, 8:07pm, fry wrote: its a polygon with a hole
|
|
|
|
|