+<script><!--
+body = document.body
+dbg = document.getElementById("jsdebug")
+canvas = document.getElementById("canvas")
+data=document.getElementById("image_serialize")
+
+image = canvas.getContext("2d")
+mouse = 0
+image_serialize=""
+
+// start and current coordinates of a draw
+// serves for tracking, whether path ends close to its beginning
+stx=0, sty=0
+cux=0, cuy=0
+
+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 + " stroke-width " + image.lineWidth
+}
+
+setcol("$tpy[color]")
+
+function relX(x){
+ if ( body.clientWidth >= 800 ){
+ return Math.floor(cscaleW * (x - canvas.offsetLeft))
+ } else {
+ return Math.floor(cscaleW * (x - canvas.offsetLeft + window.pageXOffset))
+ }
+}
+function relY(y){
+ if ( body.clientWidth >= 800 ){
+ return Math.floor(cscaleH * (y - canvas.offsetTop))
+ } else {
+ return Math.floor(cscaleH * (y - canvas.offsetTop + window.pageYOffset))
+ }
+}
+
+function draw(x, y) {
+ if ( mouse == 1){
+ cux=relX(x), cuy=relY(y)
+
+ image.lineTo( cux, cuy )
+ image.stroke()
+
+ image_serialize += " " + cux + "," + cuy