From 21db010c116bad9949b1e5df8ea1a86c3747223d Mon Sep 17 00:00:00 2001 From: Jules Date: Fri, 8 Apr 2016 21:55:54 -0400 Subject: new shaders.. add+mul buttons on webcam --- doc/shaderz.txt | 10 ++++++++++ js/photo.js | 7 ++++++- webcam.html | 9 ++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/shaderz.txt b/doc/shaderz.txt index e3581aa..4c3217f 100644 --- a/doc/shaderz.txt +++ b/doc/shaderz.txt @@ -310,8 +310,18 @@ if (x > w/2) { >> mirror brush (up-down) +Animate this on the canvas, then draw: + if (x > h/2) { lex.assign( canvas.aa[h-y][x] ) } +>> rainbow stardust brush + +Uncheck BG and animate this to brush: + +lex.fg = hue(t) +lex.char = choice(" ,'.,.','****** ") + + diff --git a/js/photo.js b/js/photo.js index 3f72cfc..d6f5f1e 100644 --- a/js/photo.js +++ b/js/photo.js @@ -108,7 +108,7 @@ var Photo = (function(){ null, null, ] - var colors = COLORS, recolor_fn = null, shade_fn = null + var colors = COLORS, recolor_fn = null, shade_fn = null, cc_recolor_fn = null var canvas = document.createElement("canvas"), ctx = canvas.getContext('2d'), pixels function set_colors (a) { @@ -120,6 +120,9 @@ var Photo = (function(){ function set_recolor_fn (fn) { recolor_fn = fn } + function set_cc_recolor_fn (fn) { + cc_recolor_fn = fn + } function closest_to(pixel){ if (recolor_fn) { @@ -162,6 +165,7 @@ var Photo = (function(){ } if (Photo.denoise) { denoise_pixel(data, w, h, i, j, pixel, Photo.denoise) } row[j] = closest_to(pixel) + if (cc_recolor_fn) row[j] = cc_recolor_fn(row[j]) } } if (! cb) return rows @@ -297,6 +301,7 @@ var Photo = (function(){ blues: BLUES, set_shade_fn: set_shade_fn, set_recolor_fn: set_recolor_fn, + set_cc_recolor_fn: set_cc_recolor_fn, set_colors: set_colors, closest_to: closest_to, distance: distance, diff --git a/webcam.html b/webcam.html index 375a00d..d541f90 100644 --- a/webcam.html +++ b/webcam.html @@ -19,6 +19,8 @@ canvas { cursor: pointer; }


+
+