+class EditableThing
+ constructor: ->
+ @el = null
+ click_proximity: (x, y) ->
+ return null
+ clicked: ->
+ update: ->
+ destructor: ->
+ if @el?
+ svg.removeChild @el
+ @el = null
+
+class PolyLine extends EditableThing
+ constructor: (args) ->
+ super args
+ @drawing = args?.drawing ? false
+ @el = document.createElementNS svg_ns, "path"
+ svg.appendChild @el
+ @points = args?.points ? []
+ @update()
+ update: (args) ->
+ if args?.drawing?
+ @drawing = args.drawing
+ d = ''
+ l = ''
+ sep = 'M'
+ for loc, i in @points
+ d += l = "#{sep} #{loc[0]} #{loc[1]}"
+ sep = ' L'
+ if args?.to_mouse?
+ d += l = "#{sep} #{args.mouse_x} #{args.mouse_y}"
+ if args?.close # FIXME ?remove
+ d += l = ' z'
+ if @points.length > 0
+ if l is " L #{@points[0][0]} #{@points[0][1]}"
+ d = d.substr 0, d.length - l.length
+ d += ' z'
+ @el.setAttribute "d", d
+ add_point: (x, y) ->
+ @points.push [x, y]
+ close_loop: ->
+ if @points.length > 2
+ @add_point @points[0][0], @points[0][1]
+