Solved

How can I calculate the area of an odd shape?

Posted on 2008-10-10
2
1,370 Views
Last Modified: 2008-12-10
I am developing a small graphics program in which users can draw a variety of shapes and then get the area of the shape by clicking inside the shape or on the shape itself. However, I've run into a problem...How can I get the area of a shape when a user clicks inside of it?

I would like to be able to calculate the area without having to store specific lines and location for each shape. Something similar to the FloodFill API would be great, where it just looks for lines that intersect of a specific color and then returns the area it found.
0
Comment
Question by:chan1928
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
Comment Utility
0
 
LVL 8

Expert Comment

by:BdLm
Comment Utility
the algo Floodfill
---------------------

       Create an empty   Pixel/ Bitarray(x,y)  x:= 0....x_max,   y:=0...y_max
       
       set all Pixel/ bits to zero  eg:  Bit(x,y) :=0 ;
     
       draw all your polygon lines on this Pixel/bitarray, set these bits to 1
       
      get a starting pixel/Bit
     
     
      repeat
            repeat
                 setall Pixel(xi,y) to your color
           until  next xi+1 Pixel is 1
            move one line up
                 
       until  can't find a Pixel(xy) = 0 in the next row          

       

can you code byyourself using drectly a Bitmap ?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now