Solved

How can I calculate the area of an odd shape?

Posted on 2008-10-10
2
1,376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to implement Singleton Design Pattern in Java.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

615 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