- unless selected?
- selected = []
- if selected.length > 0
- last = selected[selected.length - 1]
- obj = document.createElementNS("http://www.w3.org/2000/svg", "path")
- obj.setAttributeNS(null, "d", "M #{last[0]} #{last[1]} L #{x} #{y}")
- $svg[0].appendChild(obj)
- selected.push [x, y]
- console.log selected
+ unless selection?
+ path = document.createElementNS svg_ns, "path"
+ selection = data: [], element: path
+ svg.appendChild path
+ selection.data.push [x, y]
+ update_path selection.element, selection.data
+mousemove = (x, y) ->
+ mouse[0] = x
+ mouse[1] = y
+ if selection?
+ update_path selection.element, selection.data, to_mouse: true
+
+keydown = (keycode) ->
+ switch keycode
+ when 'O'.charCodeAt 0
+ return stop_close_drawing()
+ when (' '.charCodeAt 0), 13, 10, 27
+ return stop_drawing()