]> git.plutz.net Git - confetti/blobdiff - templates/therapy.html.sh
enable drawing via android-4, quicker drawing via lines
[confetti] / templates / therapy.html.sh
index d850a70d21a46dab95dbb6317b84182ec33f5446..78122fb48b42a692db0be528c38b09f75e8f983c 100755 (executable)
@@ -79,7 +79,7 @@ cat <<EOF
  --><span class=signature><input type=checkbox name="${sid}_signature" value=pos $sigcheck><button type=submit name=${sid}_sigset value=$sig></button></span>
   </label>
   <div class=tab>
-    <input class="dotmark ov" type="image" name=dotmark value="$sid" src="/therapies/${id%.tpy}_${sid}.png" alt="">
+    <img class="dotmark ov" src="/therapies/${id%.tpy}_${sid}.png" alt="">
     $(n=1; while [ -n "${tpy[${sid}_note${n}]+x}" ]; do
       t_session_note $session_n $n
       n=$(($n+1))
@@ -191,13 +191,14 @@ cat <<EOF
   data=document.getElementById("image_serialize")
 
   function setcol(c) {
-    image.fillStyle = c
-    image_serialize += " fill " + c
+    image.strokeStyle = c
+    image.lineWidth = 2
+    image_serialize += " stroke " + c
   }
 
   setcol("$tpy[color]")
 
-  function circle(x, y) {
+  function draw(x, y) {
     if ( mouse == 1){
       if ( body.clientWidth >= 800 ){
         sx=Math.floor(cscaleW * (x - canvas.offsetLeft))
@@ -206,12 +207,10 @@ cat <<EOF
         sx=Math.floor(cscaleW * (x - canvas.offsetLeft + body.scrollLeft))
         sy=Math.floor(cscaleH * (y - canvas.offsetTop + body.scrollTop))
       }
-      image.beginPath()
-      image.arc( sx, sy, 5, 0, 2 * Math.PI )
-      image.fill()
-      image.closePath()
+      image.lineTo( sx, sy )
+      image.stroke()
 
-      image_serialize += " circle " + sx + "," + sy + " " + (sx-5) + "," + sy
+      image_serialize += " " + sx + "," + sy
     }
   }
 
@@ -221,21 +220,24 @@ cat <<EOF
     cscaleW = canvas.width / canvas.clientWidth
     cscaleH = canvas.height / canvas.clientHeight
 
-    circle(x, y)
+    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)  {    circle(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) {    circle(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>
 </form>