Calculating area outside of an ARC

M

marty.gagnon

I'm using drawArc() to draw an arc inside the bounds of a rectangle.
I could use fillArc() to fill the area contained inside the bounds of
the arc but I'm interested in
filling the area inbetween the outside of the arc and the containing
rectangle.
I though I about using fillPoly() but I need the points of the arc and
I'm not sure
how to get that. How can I get the x,y points of the arc? Is this the
best approach?

_______________
| fill this _-/
| _-/
| / Inside of
| / Arc
|

Any suggestions?

Thanks
Marty Gagnon
Shawnee, KS.
 
O

Oliver Wong

I'm using drawArc() to draw an arc inside the bounds of a rectangle.
I could use fillArc() to fill the area contained inside the bounds of
the arc but I'm interested in
filling the area inbetween the outside of the arc and the containing
rectangle.
I though I about using fillPoly() but I need the points of the arc and
I'm not sure
how to get that. How can I get the x,y points of the arc? Is this the
best approach?

_______________
| fill this _-/
| _-/
| / Inside of
| / Arc
|

Any suggestions?

I'm not much of a graphics guru, so maybe someone else will have a
better suggestion, but until then...

If you know how that the background is white, for example, and you want
to fill the exterior with blue, then paint a blue rectangle, then paint a
white arc over the blue rectangle.

If you don't know that the background is white, you could try using
tricks with masks so as to paint the rectangle, then "unpaint" the region
under the arc.

If you have anti-aliasing turned off, you could try painting the
rectangle, and then the arc on an offsurface buffer, and then copy and paint
the image of that buffer onto your target buffer with parts of the image
being transparent.

If you want to go with fillPoly, you could either use a straight-edge
poly and approximate the arc with lots of points (search math sites to find
the formula for arcs). Otherwise, you might be better off using nurbs.

- Oliver
 
C

Chris Smith

I'm using drawArc() to draw an arc inside the bounds of a rectangle.
I could use fillArc() to fill the area contained inside the bounds of
the arc but I'm interested in
filling the area inbetween the outside of the arc and the containing
rectangle.

If you're using any remotely modern Java platform, then you can cast the
Graphics object to Graphics2D, and do this fairly easily:

import java.awt.geom.*;

...

Graphics2D g = (Graphics2D) ...;
Rectangle2D rect = ...;
Arc2D arc = ...;

Area a = new Area(rect);
a.subtract(new Area(arc);

g.fill(a);

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top