X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=static%2Ftherapy_draw.js;h=8266ac50d3429ff394169a918fbde0aadbb10a2e;hp=5a06728683532f1888753042794ab06bf8c79b3e;hb=e4a974a6b990f9f5fb521303b82ef6289f6027fa;hpb=bafaa4cafbc86cc32e11e24b3f34033ffd84905b diff --git a/static/therapy_draw.js b/static/therapy_draw.js index 5a06728..8266ac5 100644 --- a/static/therapy_draw.js +++ b/static/therapy_draw.js @@ -29,16 +29,17 @@ image_serialize="" stx=0, sty=0 cux=0, cuy=0 +function setstroke(w) { + image.lineWidth = w + data.value += " stroke-width " + image.lineWidth +} function setcol(c) { this.c = c image.strokeStyle = c image.fillStyle = c - if ( c == "#FFF" ) image.lineWidth = 32 - else image.lineWidth = 4 - data.value += " stroke " + c + "F" + " stroke-width " + image.lineWidth + data.value += " stroke " + c + "F" } - function relX(x){ if ( body.clientWidth >= 800 ){ return Math.floor(cscaleW * (x - canvas.offsetLeft)) @@ -73,6 +74,9 @@ function drawstart(x, y) { stx=relX(x), sty=relY(y) + document.getElementsByName("penwidth").forEach( + function(x, y, z){ if (x.checked) setstroke(x.value); } + ); document.getElementsByName("color").forEach( function(x, y, z){ if (x.checked) setcol(x.value); } ); @@ -86,7 +90,7 @@ function drawstart(x, y) { function drawstop() { // if path ends close to beginning ( < 50 px); then close path and fill - if ( mouse == 1 && Math.sqrt( Math.pow(stx - cux, 2) + Math.pow(sty - cuy, 2)) <= 50 && c !== "#FFF" ){ + if ( false && mouse == 1 && Math.sqrt( Math.pow(stx - cux, 2) + Math.pow(sty - cuy, 2)) <= 50 && c !== "#FFF" ){ image.lineTo( stx, sty ) image.stroke()