summaryrefslogtreecommitdiff
path: root/js/app.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-11-22 10:17:49 -0500
committerJules Laplace <jules@okfoc.us>2014-11-22 10:17:49 -0500
commit9ab497b693d34e10b9db2d7603917d8d1296e350 (patch)
tree81dd8ae4a595ce4a437f34c3b1ca3de44a5460e0 /js/app.js
parent69e0de28cb98b90d630c76d25f483ba59802d1d2 (diff)
fix width/height
Diffstat (limited to 'js/app.js')
-rw-r--r--js/app.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/js/app.js b/js/app.js
index 1e975ea..9db7895 100644
--- a/js/app.js
+++ b/js/app.js
@@ -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)
}
}