From: Jason Woofenden Date: Sun, 24 May 2015 16:56:26 +0000 (-0400) Subject: initial spike X-Git-Url: https://jasonwoof.com/gitweb/?p=crayon_mockup.git;a=commitdiff_plain;h=c8077c7a5c9ce3610d8f926b7fdf8969974728c8 initial spike --- diff --git a/.git-ftp-include b/.git-ftp-include new file mode 100644 index 0000000..3d4c4c2 --- /dev/null +++ b/.git-ftp-include @@ -0,0 +1 @@ +auto.js:auto.coffee diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..31c8cde --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/auto.js diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cc4e070 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +objects= auto.js + +all: $(objects) + +clean: + rm -f $(objects) + +%.js: %.coffee + coffee -c $< diff --git a/auto.coffee b/auto.coffee new file mode 100644 index 0000000..7a55b2a --- /dev/null +++ b/auto.coffee @@ -0,0 +1,36 @@ +# globals +$svg = null #jquery object for svg element +selected = null + +stop_drawing = -> + selected = null +click = (x, y) -> + 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 + +# called automatically on domcontentloaded +init = -> + $container = $ '.crayon_mockup' + $stop_button = $ '
[end current polyline]
' + $tools = $ '
' + $tools.append $stop_button + $stop_button.click stop_drawing + $container.append $tools + $svg = $ '' + #$test_path = $ '' + #$svg.append $test_path + $container.append $svg + console.log 'hi' + $svg.mousedown (e) -> + console.log 'hi' + offset = $svg.offset() + click e.pageX - offset.left, e.pageY - offset.top + +$ init diff --git a/index.html b/index.html new file mode 100644 index 0000000..6120612 --- /dev/null +++ b/index.html @@ -0,0 +1,25 @@ + + + + Crayon Mockup (working title) + + + + + +

Crayon Mockup (working title)

+

Instructions: click in multiple different places in the box below to draw

+
+ +