+<script><!--
+body = document.body
+canvas = document.getElementById("canvas")
+dbg = document.getElementById("jsdebug")
+image = canvas.getContext("2d")
+mouse = 0
+image_serialize=""
+data=document.getElementById("image_serialize")
+
+function setcol(c) {
+ image.strokeStyle = c
+ if ( c == "#FFF" ) image.lineWidth = 32
+ else image.lineWidth = 4
+ image_serialize += " stroke " + c + " stroke-width " + image.lineWidth
+}
+
+setcol("$tpy[color]")
+
+function draw(x, y) {
+ if ( mouse == 1){
+ if ( body.clientWidth >= 800 ){
+ sx=Math.floor(cscaleW * (x - canvas.offsetLeft))
+ sy=Math.floor(cscaleH * (y - canvas.offsetTop))
+ } else {
+ sx=Math.floor(cscaleW * (x - canvas.offsetLeft + window.pageXOffset))
+ sy=Math.floor(cscaleH * (y - canvas.offsetTop + window.pageYOffset))
+ }
+ image.lineTo( sx, sy )
+ image.stroke()
+
+ image_serialize += " " + sx + "," + sy
+ }
+}
+
+function drawstart(x, y) {
+ mouse = 1
+
+ cscaleW = canvas.width / canvas.clientWidth
+ cscaleH = canvas.height / canvas.clientHeight
+
+ image_serialize += " polyline"
+ image.beginPath()
+ draw(x, y)
+}
+function drawstop() {
+ mouse = 0
+ image.closePath()
+ //dbg.innerHTML = image_serialize
+ data.value = image_serialize
+}
+
+window.addEventListener( 'mouseup', function() { drawstop() } )
+canvas.addEventListener( 'mousedown', function(e) { drawstart(e.clientX, e.clientY) } )
+canvas.addEventListener( 'mousemove', function(e) { draw(e.clientX, e.clientY) } )
+
+window.addEventListener( 'touchend', function() { drawstop() } )
+canvas.addEventListener( 'touchstart', function(e) { drawstart(e.touches[0].clientX, e.touches[0].clientY) } )
+canvas.addEventListener( 'touchmove', function(e) { e.preventDefault(); draw(e.touches[0].clientX, e.touches[0].clientY) } )
+--></script>