From 17f2644e3d885c8aef170023c84933e5bd888402 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 10 May 2016 15:58:52 -0400 Subject: more convenient canvas.get syntax.. --- doc/shaders/util.txt | 13 +++++++++++++ index.html | 9 +++++---- js/matrix.js | 7 +++++++ js/ui/controls.js | 2 +- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/doc/shaders/util.txt b/doc/shaders/util.txt index d192652..a455eb3 100644 --- a/doc/shaders/util.txt +++ b/doc/shaders/util.txt @@ -23,3 +23,16 @@ Tip: Set to "animate brush", then use option+shift (alt+shift) to copy color from the canvas. Brush will have the "shape" of the copied color only. Can be a cool effect when used with fg/bg only. + + +>> copy color from canvas at x/y + +lex.assign( canvas.get(x,y) ) + + + +>> animate canvas up and to the left.. + +lex.assign( canvas.get(x+1,y+1) ) + + diff --git a/index.html b/index.html index ee9b646..0f0f10d 100644 --- a/index.html +++ b/index.html @@ -91,10 +91,11 @@ diff --git a/js/matrix.js b/js/matrix.js index 275e6b6..de59e17 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -151,6 +151,13 @@ Matrix.prototype.getCell = function(x,y){ if (this.aa[y] && this.aa[y][x]) return this.aa[y][x] else return null } +Matrix.prototype.get = function(x,y){ + y = floor(mod(y || 0, this.h)) + x = floor(mod(x || 0, this.w)) + if (this.aa[y] && this.aa[y][x]) return this.aa[y][x] + else return null +} + Matrix.prototype.resize = function(w,h){ w = w || canvas.w h = h || canvas.h diff --git a/js/ui/controls.js b/js/ui/controls.js index c191cc2..9139989 100644 --- a/js/ui/controls.js +++ b/js/ui/controls.js @@ -37,6 +37,7 @@ var controls = (function(){ controls.text = new Tool (text_el) controls.text.use = function(){ + current_filetool && current_filetool.blur() } controls.select = new Tool (select_el) @@ -111,7 +112,6 @@ var controls = (function(){ if (! selection.hidden) selection.reposition() this.update( state ) } - ClipboardTool = FileTool.extend({ blur: function(){ this.__blur() -- cgit v1.2.3-70-g09d2