summaryrefslogtreecommitdiff
path: root/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/app.js')
-rw-r--r--js/app.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/js/app.js b/js/app.js
index 9cd9cf8..a5e3aea 100644
--- a/js/app.js
+++ b/js/app.js
@@ -29,6 +29,7 @@ function build () {
})
shader.init()
shader.run(canvas)
+ shader.animate()
brush = new Matrix (5, 5, function(x,y){
var lex = new Lex (x,y)
@@ -39,6 +40,7 @@ function build () {
var lex = new Lex (x,y)
lex.bg = colors[color_hue_order[y>>1]]
lex.build()
+ console.log(lex.bg, lex.css())
return lex
})
canvas.append(canvas_rapper)
@@ -98,7 +100,8 @@ function build () {
controls.shader = new Tool (shader_el)
controls.shader.use = function(){
shader_textarea.style.display = "block"
- setTimeout(function(){ shader_textarea.focus() })
+ // setTimeout(function(){ shader_textarea.focus() })
+ shader_textarea.focus()
}
controls.shader.blur = function(){
Tool.prototype.blur.call(this)
@@ -116,6 +119,7 @@ function build () {
controls.canvas_height = new Lex (canvas_height_el)
controls.circle.focus()
+// controls.shader.focus()
brush.bg = colors.red
brush.generate()
@@ -162,6 +166,7 @@ function bind () {
})
window.addEventListener('mouseup', function(){
dragging = erasing = false
+ if (current_tool.name != 'shader') { cursor_input.focus() }
});
[controls.width, controls.height, controls.canvas_width, controls.canvas_height].forEach(function(lex){
@@ -214,15 +219,26 @@ function bind () {
canvas.build()
})
- window.addEventListener('keydown', function(e){
+ window.addEventListener('mousedown', function(e){
+ if (current_tool.name == "shader") { return }
+ cursor_input.focus()
+ })
+ cursor_input.addEventListener('keydown', function(e){
+ if (focused) { focused.key(undefined, e.keyCode) }
+ })
+ cursor_input.addEventListener('input', function(e){
if (current_tool.name == "shader") {
+ cursor_input.value = ""
return
}
if (! e.metaKey && ! e.ctrlKey && ! e.altKey) {
e.preventDefault()
}
+ var char = cursor_input.value
+ cursor_input.value = ""
- // console.log(e.keyCode)
+ // var charFromKeyCode = String.fromCharCode(e.keyCode)
+
switch (e.keyCode) {
case 27: // esc
if (focused) focused.blur()
@@ -238,12 +254,14 @@ function bind () {
break
}
default:
- if (focused) focused.key(String.fromCharCode(e.keyCode), e.keyCode)
+ if (focused) focused.key(char, e.keyCode)
break
}
})
-
+
+
document.addEventListener('DOMContentLoaded', function(){
+ if (current_tool.name != 'shader') { cursor_input.focus() }
document.body.classList.remove('loading')
})
}