Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1379
  • Last Modified:

How can I calculate the area of an odd shape?

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
chan1928
Asked:
chan1928
1 Solution
 
BdLmCommented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now