From 4a674cd3089346a02f6ffd3e6686e3b7fd01a367 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 21 Nov 2014 23:29:44 -0500 Subject: shader --- js/app.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'js/app.js') diff --git a/js/app.js b/js/app.js index 3f2a206..4c5100a 100644 --- a/js/app.js +++ b/js/app.js @@ -22,14 +22,9 @@ function init () { function build () { canvas = new Matrix (cols, rows, function(x,y){ var lex = new Lex (x,y) - if (x > y || y > x + 20 || x > y / 4 + 10) { - lex.clear() - } - else { - lex.bg = x+y*y - lex.fg = (x+y)%2 - lex.char = ":" - } + // + shader(lex, x, y) + // lex.build() return lex }) @@ -90,6 +85,8 @@ function build () { controls.width = new Lex (width_el) controls.height = new Lex (height_el) + controls.canvas_width = new Lex (canvas_width_el) + controls.canvas_height = new Lex (canvas_height_el) controls.circle.focus() @@ -144,7 +141,7 @@ function bind () { dragging = erasing = false }); - [controls.width, controls.height].forEach(function(lex){ + [controls.width, controls.height, controls.canvas_width, controls.canvas_height].forEach(function(lex){ lex.span.addEventListener('mousedown', function(e){ lex.focus() }) @@ -170,6 +167,22 @@ function bind () { brush.h = n brush.rebuild() }) + + controls.canvas_width.key = int_key(function(n, keyCode){ + controls.canvas_width.blur() + controls.canvas_width.char = ""+n + controls.canvas_width.build() + brush.w = n + brush.rebuild() + }) + controls.canvas_height.key = int_key(function(n, keyCode){ + controls.canvas_height.blur() + controls.canvas_height.char = ""+n + controls.canvas_height.build() + brush.h = n + brush.rebuild() + }) + window.addEventListener('keydown', function(e){ if (! e.metaKey && ! e.ctrlKey && ! e.altKey) { e.preventDefault() -- cgit v1.2.3-70-g09d2