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)
   how to draw an arc?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: how to draw an arc?  (Read 241 times)
mcbluebeard


how to draw an arc?
« on: Dec 23rd, 2003, 4:28am »

Hi!
 
I'd like to fill an area between radius_1
and radius_2, as well as degree_1 and degree_2.
 
Such a thing is possible with the java fillArc()
method...but (and this is an awe-inspiring display of  
idiocy) I can't figure out how to do this using  
processing.  Any help would be *greatly* appreciated!
 
Best, kyle
 
vent

WWW
Re: how to draw an arc?
« Reply #1 on: Dec 23rd, 2003, 5:33am »

Give this a try:
Code:

void setup(){
  size(400,400);
}
void loop(){
  background(0);
  beginShape( POLYGON );
  //regular point
  bezierVertex(50, 100);
  //anchor point
  bezierVertex(50+mouseX, 50);
  //anchor point
  bezierVertex(150, mouseY );
  //regular point
  bezierVertex( 100, 200 );
  endShape();
}

 
 

http://www.shapevent.com/
toxi

WWW
Re: how to draw an arc?
« Reply #2 on: Dec 23rd, 2003, 10:22pm »

this came up a few times in the past. here's some code using triangle strips. it won't look pretty with stroke() turned on...
 
Code:
void setup(){
  size(400,400);
}
 
void loop() {
  background(51);
  // center x,y
  float cx=200;
  float cy=200;
  // start/end angles
  float a1=-PI/8;
  float a2=TWO_PI/3;
  // number of steps
  float steps=12;
  float stepSize=(a2-a1)/steps;
  // inner/outer radius
  float r1=abs(cx-mouseX);
  float r2=abs(cy-mouseY);
  // colour
  fill(255,0,0);
  noStroke();
  beginShape(TRIANGLE_STRIP);
  for (float i = a1; i <= a2; i +=stepSize) {
    vertex(r1*cos(i)+cx, r1*sin(i)+cy);
    vertex(r2*cos(i)+cx, r2*sin(i)+cy);
  }
  endShape();
}

 
hth!
 

http://toxi.co.uk/
mcbluebeard


Re: how to draw an arc?
« Reply #3 on: Dec 30th, 2003, 4:13am »


Thanks so much toxi -- I appreciate your help!
It works like a champ.
 
Pages: 1 

« Previous topic | Next topic »