From a4c301d2c58e6c56b98766edbfee0d40d49add42 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 9 Jun 2016 16:16:31 -0400 Subject: colorize tool --- js/ui/nopaint.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'js/ui') diff --git a/js/ui/nopaint.js b/js/ui/nopaint.js index c76d269..74ddadf 100644 --- a/js/ui/nopaint.js +++ b/js/ui/nopaint.js @@ -486,7 +486,6 @@ var nopaint = (function(){ var shape = choice(this.shapes) this.reorient( last_brush ) brush.char = " " - console.log(shape[0].length, shape.length) brush.resize(shape[0].length, shape.length) brush.generate() brush.rebuild() @@ -671,8 +670,6 @@ var nopaint = (function(){ var ShaderTool = NopaintTool.extend({ type: "shader", - dx: 0, - dy: 0, speed: 3, is_shader: true, is_recursive: false, @@ -706,6 +703,24 @@ var nopaint = (function(){ } }) + var ColorizeTool = ShaderTool.extend({ + type: "colorize", + fns: [mirc_color_reverse,hue,inv_hue,gray,fire,red,yellow,green,blue,purple,dark_gray], + speed: 5, + start: function(){ + this.__start() + this.i = randint(this.fns.length) + }, + before_shade: function(){ + this.i = (this.i + 1) % this.fns.length + this.fn = this.fns[this.i] + }, + shade: function(src, dest, lex, x, y, w, h){ + lex.bg = this.fn( lex.bg ) + return false + }, + }) + var TranslateTool = ShaderTool.extend({ type: "translate", dx: 0, @@ -833,6 +848,7 @@ var nopaint = (function(){ nopaint.add_tool( new CycleTool({ weight: 1 }) ) nopaint.add_tool( new ScaleTool({ weight: 3 }) ) nopaint.add_tool( new RotateTool({ weight: 3 }) ) + nopaint.add_tool( new ColorizeTool({ weight: 1 }) ) nopaint.regenerate_weights() nopaint.toggle(true) -- cgit v1.2.3-70-g09d2