hi,
this should help:
----------------------------------------------
<svg>
<script type="text/ecmascript">
<![CDATA[
function getPolygonArea(evt) {
var coords = evt.target.getAttribute('points').split(/
[, ]/);
area = 0;
for (i=0; i<coords.length; i+=2) area += (coords[i] *
coords[(i+3) % coords.length] - coords[(i+2) % coords.length] * coords
[i+1]);
area /= 2;
alert(area);
}
]]>
</script>
<polygon onclick="getPolygonArea(evt)"
style="fill:#ff0000;stroke:#000000;stroke-width:1px" points="10 10
200 10 180 300 10 200"/>
</svg>
----------------------------------------------
cheers, higorion
--- In [email protected], "magicbrigth"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I want to calculate area of a polygon by clicking the vertex
points. When
> I clicked the first point again, I want to show area of the polygon
on the
> alert window. I need a JavaScript for this calculation. Are there
any
> samples? Can anybody help me?
>
> Sincerely...
>
> //this is my sample data.
>
> <?xml version='1.0' standalone='no'?>
> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN'
> 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
> <svg width='365' height='365' viewBox='28395 -30825 45 40'
> xmlns='http://www.w3.org/2000/svg'>
> <polygon points='28400.0,-30800.0 28414.285,-30821.969 28426.414,-
30797.799'
> style='fill:none; stroke:red; stroke-width:0.7'/>
> <polygon points='28400.27,-30816.758 28429.29,-30814.06 28414.285,-
30790.252'
> style='fill:none; stroke:blue; stroke-width:0.7'/>
> <g style='stroke:black; stroke-width:.25; fill:white'>
> <circle cx='28400.0' cy='-30800.0' r='0.35' />
> <circle cx='28400.27' cy='-30816.758' r='0.35' />
> <circle cx='28414.285' cy='-30821.969' r='0.35' />
> <circle cx='28429.29' cy='-30814.06' r='0.35' />
> <circle cx='28426.414' cy='-30797.799' r='0.35' />
> <circle cx='28414.285' cy='-30790.252' r='0.35' />
> </g>
> <circle cx='28410.291' cy='-30815.826' r='0.35' style='fill:white;
> stroke:black; stroke-width:0.25'/>
> <circle cx='28405.035' cy='-30807.744' r='0.35' style='fill:white;
> stroke:black; stroke-width:0.25'/>
> <circle cx='28417.713' cy='-30815.137' r='0.35' style='fill:white;
> stroke:black; stroke-width:0.25'/>
> <circle cx='28423.146' cy='-30804.312' r='0.35' style='fill:white;
> stroke:black; stroke-width:0.25'/>
> <circle cx='28419.408' cy='-30798.383' r='0.35' style='fill:white;
> stroke:black; stroke-width:0.25'/>
> <circle cx='28409.55' cy='-30799.203' r='0.35' style='fill:white;
> stroke:black; stroke-width:0.25'/>
> </svg>
>
>
>
______________________________________________________________________
______
> �m�r boyu de�i�meyecek email adresinizi �imdi
al�n: Mynet Email Plus
-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/