+
+ // 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" ){
+ image.lineTo( stx, sty )
+ image.stroke()
+
+ image.globalAlpha = .5
+ image.fill()
+ image.globalAlpha = 1
+
+ image_serialize += " " + stx + "," + sty
+ data.value += " fill " + c + "8" + image_serialize
+ } else if (mouse == 1) {
+ data.value += " fill #0000 " + image_serialize
+ }
+ dbg.innerHTML = " stx: " + stx + " cux: " + cux + " sty: " + sty + " cuy: " + cuy
+
+ image.closePath()
+ image_serialize = ""
+ mouse = 0