(event)
| 25 | } |
| 26 | |
| 27 | function draw(event){ |
| 28 | //if not painting , then return |
| 29 | if(!painting) return; |
| 30 | |
| 31 | ctx.lineWidth = rangeElement.value; |
| 32 | ctx.lineCap = 'round'; |
| 33 | ctx.strokeStyle = colorElement.value; |
| 34 | |
| 35 | ctx.lineTo(event.clientX, event.clientY); |
| 36 | ctx.stroke(); |
| 37 | |
| 38 | ctx.beginPath(); |
| 39 | ctx.moveTo(event.clientX, event.clientY); |
| 40 | } |
| 41 | |
| 42 | window.addEventListener('mousedown', startDrawing); |
| 43 | window.addEventListener('mouseup', stopDrawing); |