summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/shaderz.txt10
-rw-r--r--js/photo.js7
-rw-r--r--webcam.html9
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; }
<label for="sat_el">sat</label><input type="range" min="-1" max="1" value="0" step="0.005" id="sat_el"><br>
<label for="lum_el">lum</label><input type="range" min="-1" max="1" value="0" step="0.005" id="lum_el"><br>
<label for="quant_el">quantize</label><input type="range" min="1" max="255" value="1" step="1" id="quant_el"><br>
+ <label for="cc_add_el">add</label><input type="range" min="0" max="15" value="0" step="1" id="cc_add_el"><br>
+ <label for="cc_mul_el">mul</label><input type="range" min="0" max="15" value="0" step="1" id="cc_mul_el"><br>
<label for="palette_el" style="padding-top: 5px;">palette</label>
<select id="palette_el">
<option default value="colors">all colors</label>
@@ -102,6 +104,9 @@ Photo.set_recolor_fn(function(rgb){
}
return rgb
})
+Photo.set_cc_recolor_fn(function(bg){
+ return (cc_mul * bg + cc_add) % 16
+})
var shader_index = 0
@@ -168,11 +173,13 @@ function rgbpixel(d, p, x, y, w, h) {
// Photo.denoise = 2
-var hue = 0, sat = 0, lum = 0, quant = 1
+var hue = 0, sat = 0, lum = 0, quant = 1, cc_add = 0, cc_mul = 1
listen(hue_el, window, "hue")
listen(sat_el, window, "sat")
listen(lum_el, window, "lum")
listen(quant_el, window, "quant")
+listen(cc_add_el, window, "cc_add")
+listen(cc_mul_el, window, "cc_mul")
save_el.addEventListener('click', save)
function save (){