diff options
Diffstat (limited to 'js/app.js')
| -rw-r--r-- | js/app.js | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -1,7 +1,7 @@ var contentType = 'text/plain;charset=utf-8' -var cols = 200 -var rows = 200 +var cols = 80 +var rows = 24 var dragging = false var drawing = true var erasing = false @@ -84,7 +84,13 @@ function build () { } controls.text.generate = function(){ } - + + controls.clear = new Tool (clear_el) + controls.clear.use = function(){ + canvas.clear() + } + + controls.width = new Lex (width_el) controls.height = new Lex (height_el) controls.canvas_width = new Lex (canvas_width_el) @@ -108,18 +114,14 @@ function bind () { erasing = (e.which == "3" || e.ctrlKey) draw(lex, x, y, erasing) } - else { - lex.focus() - } + lex.focus() }) lex.span.addEventListener("mousemove", function(){ if (! dragging) return if (drawing) { draw(lex, x, y, erasing) } - else { - lex.focus() - } + lex.focus() }) }) palette.forEach(function(lex, x, y){ @@ -149,7 +151,7 @@ function bind () { }) }); - [controls.square, controls.circle, controls.text].forEach(function(tool){ + [controls.square, controls.circle, controls.text, controls.clear].forEach(function(tool){ tool.span.addEventListener('mousedown', function(e){ tool.focus() }) @@ -171,22 +173,20 @@ function bind () { }) controls.canvas_width.key = int_key(function(n, keyCode){ + controls.canvas_width.read() if (controls.canvas_width.char.length == 1) { n = parseInt(controls.canvas_width.char) * 10 + n } - controls.canvas_width.blur() controls.canvas_width.char = ""+n controls.canvas_width.build() canvas.w = n canvas.rebuild() }) controls.canvas_height.key = int_key(function(n, keyCode){ - console.log(controls.canvas_height.char.length) - console.log(controls.canvas_height.char,n) + controls.canvas_height.read() if (controls.canvas_height.char.length == 1) { n = parseInt(controls.canvas_height.char) * 10 + n } - controls.canvas_height.blur() controls.canvas_height.char = ""+n controls.canvas_height.build() canvas.h = n @@ -221,7 +221,7 @@ function bind () { function int_key (f) { return function (key, keyCode) { var n = parseInt(key) - n && f(n) + ! isNaN(n) && f(n) } } |
