Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I calculate the area of an odd shape?

Posted on 2008-10-10
2
Medium Priority
?
1,378 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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This video teaches viewers about errors in exception handling.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

688 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