views:

923

answers:

2

I'm using KImageMapEditor on Linux (Ubuntu) to create an image map. The shapes in the image are a little complex so I'm using the freehand tool to draw them. However, this is really the same as the polygon tool so the shapes have ended up with a lot of points, which has made the HTML pretty huge.

Does anyone know of a way to reduce the complexity of the shapes, like "smoothing out" the lines?

I should also mention the reason I want the shapes to be fairly accurate is because I'm intending to do something like this, where each shape is highlighted on mouseover: http://davidlynch.org/js/maphilight/docs/demo%5Fusa.html

+1  A: 

Since users aren't going to click to the pixel, give them some leeway and create a "sloppy" map which roughly outlines each shape instead of clinging to the actual pixel outline.

This is in the same way as you don't expect a click on a link to fail just because you click on the background which shines through the text. You expect the bounding box of the text to act as the click-able area instead of the "black pixels".

Aaron Digulla
I see your point, but I'm hoping to add en effect like this: http://davidlynch.org/js/maphilight/docs/demo_usa.html - which would look bad if a large square surrounding each shape. I might be able to find a compromise, though.
DisgruntledGoat
For map highlights, create transparent PNGs and use JS to overlay them on the map when you get hover events. This allows you to use the full power of your image manipulation program for effects.
Aaron Digulla
A: 

Algorithm: Given three consecutive points, eliminate the middle point if the angle created is less than some tolerated error e. Polygonal path simplification with angle constraint

Jóhann Þórir Jóhannsson