Solved

How can I calculate the area of an odd shape?

Posted on 2008-10-10
2
1,372 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
ID: 22688551
0
 
LVL 8

Expert Comment

by:BdLm
ID: 22694812
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Add a task in Outlook from access 11 40
SQL VB connection works in one PC and doesn't in another 15 64
Problem to open text file 11 113
Not seen Link button 5 41
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

831 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