Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

Calculating area outside of an ARC

Thread view: 
marty.gagnon@imagenow.com - 22 Nov 2005 16:48 GMT
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.
Oliver Wong - 22 Nov 2005 16:54 GMT
> 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
[quoted text clipped - 13 lines]
>
> 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
Chris Smith - 22 Nov 2005 17:26 GMT
> 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);

Signature

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

marty.gagnon@imagenow.com - 22 Nov 2005 19:24 GMT
Thanks, I like that approach.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.