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
Medium Priority
1,378 Views
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
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

LVL 84

Accepted Solution

ozo earned 2000 total points
ID: 22688551
0

LVL 8

Expert Comment

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
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

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.
###### Suggested Courses
Course of the Month5 days, 13 hours left to enroll