Finding the centroid of a polygon?

The formula is given here for vertices sorted by their occurance along the polygon’s perimeter. For those having difficulty understanding the sigma notation in those formulas, here is some C++ code showing how to do the computation: #include <iostream> struct Point2D { double x; double y; }; Point2D compute2DPolygonCentroid(const Point2D* vertices, int vertexCount) { Point2D … Read more

SVG rounded corner

Here is how you can create a rounded rectangle with SVG Path: <path d=”M100,100 h200 a20,20 0 0 1 20,20 v200 a20,20 0 0 1 -20,20 h-200 a20,20 0 0 1 -20,-20 v-200 a20,20 0 0 1 20,-20 z” /> Explanation m100,100: move to point(100,100) h200: draw a 200px horizontal line from where we are … Read more

Do I use , , or for SVG files?

I can recommend the SVG Primer (published by the W3C), which covers this topic: http://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#SVG_in_HTML If you use <object> then you get raster fallback for free*: <object data=”https://stackoverflow.com/questions/4476526/your.svg” type=”image/svg+xml”> <img src=”https://stackoverflow.com/questions/4476526/yourfallback.jpg” /> </object> *) Well, not quite for free, because some browsers download both resources, see Larry’s suggestion below for how to get around that. … Read more