X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=therapies%2Ftherapy_draw.js;h=19542c8e2cca88cb5a91d0f582abec1d2076f5ca;hb=be67cb59512145a0fa5b8c6686996f3876618570;hp=8a8e936c6873b443a0d7ba0799b491e7f5d50f7e;hpb=531f71462dfbc0eeebd74c74c84323c14475f51a;p=lobster diff --git a/therapies/therapy_draw.js b/therapies/therapy_draw.js index 8a8e936..19542c8 100644 --- a/therapies/therapy_draw.js +++ b/therapies/therapy_draw.js @@ -1,4 +1,4 @@ -// Copyright 2016 Paul Hänsch +// Copyright 2016, 2020 Paul Hänsch // // This file is part of Confetti. // @@ -18,11 +18,15 @@ body = document.body dbg = document.getElementById("jsdebug") canvas = document.getElementById("canvas") -data=document.getElementById("image_serialize") +data = document.getElementById("image_serialize") image = canvas.getContext("2d") mouse = 0 image_serialize="" +image.lineJoin = "round" +image.lineCap = "round" +data.value += " stroke-linejoin round " +data.value += " stroke-linecap round " // start and current coordinates of a draw // serves for tracking, whether path ends close to its beginning @@ -77,16 +81,16 @@ function drawstart(x, y) { setstroke(document.querySelector('input[name="penwidth"]:checked').value); setcol(document.querySelector('input[name="color"]:checked').value); - image.beginPath() - draw(x, y) // why must this not use relative Coords ??? + image.beginPath(); + draw(x, y); // why must this not use relative Coords ??? - image_serialize = " polyline" + image_serialize = " polyline " + stx + "," + sty; } function drawstop() { // if path ends close to beginning ( < 50 px); then close path and fill - if ( false && mouse == 1 && Math.sqrt( Math.pow(stx - cux, 2) + Math.pow(sty - cuy, 2)) <= 50 && c !== "#FFF" ){ + if ( mouse == 1 && Math.sqrt( Math.pow(stx - cux, 2) + Math.pow(sty - cuy, 2)) <= 50 && c !== "#FFF" ){ image.lineTo( stx, sty ) image.stroke()