-
-
Save NHQ/4ab9b059329c8ae2d778 to your computer and use it in GitHub Desktop.
paste into http://substack.neocities.org/video.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
q = quantize(1.9) | |
return function (r, w) { | |
for (var i = 0; i < w.data.length; i += 4) { | |
var v = q([r.data[i], r.data[i+1], r.data[i+2]]) | |
w.data[i] = v; | |
w.data[i+1] = v; | |
w.data[i+2] = v; | |
w.data[i+3] = 255; | |
} | |
} | |
function quantize(x){ | |
var z = 255 * 3 | |
var q = z / x | |
return function(pixels){ | |
var totes = pixels.reduce(function(a, e){ | |
return a + e | |
},0) | |
return Math.floor(totes / q) * q | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = quantizeColor(120) | |
gee = quantizeColor(120) | |
bee = quantizeColor(120) | |
q = quantize(2) | |
return function (r, w) { | |
for (var i = 0; i < w.data.length; i += 4) { | |
var v = q([r.data[i], r.data[i+1], r.data[i+2]]) | |
w.data[i] = arr(r.data[i]) * v / 255; | |
w.data[i+1] = gee(r.data[i+1]) * v / 255; | |
w.data[i+2] = bee(r.data[i+2]) * v / 255; | |
w.data[i+3] = 255; | |
} | |
} | |
function quantize(x){ | |
var z = 255 * 3 | |
var q = z / x | |
return function(pixels){ | |
var totes = pixels.reduce(function(a, e){ | |
return a + e | |
},0) | |
return Math.floor(totes / q) * q | |
} | |
} | |
function quantizeColor(x){ | |
var z = 255 | |
var q = z / x | |
return function(totes){ | |
return Math.floor(totes / q) * q | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var QUANTASTICALLY = 7 | |
q = quantize(QUANTASTICALLY) | |
return function (r, w) { | |
for (var i = 0; i < w.data.length; i += 4) { | |
v = q([r.data[i], r.data[i+1], r.data[i+2]]) | |
w.data[i] = v; | |
w.data[i+1] = v; | |
w.data[i+2] = v; | |
w.data[i+3] = 255; | |
} | |
} | |
function quantize(x){ | |
var z = 255 * 3 | |
var q = 255 / x | |
return function(pixels){ | |
var totes = pixels.reduce(function(a, e){ | |
return a + ( (e / 255)) | |
},0) / 3 | |
return Math.floor(totes * 255 / q) * q | |
} | |
} | |
function quantizeColor(x){ | |
var z = 255 | |
var q = z / x | |
return function(totes){ | |
return Math.ceil(totes / q) * q | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = quantizeColor(120) | |
gee = quantizeColor(120) | |
bee = quantizeColor(120) | |
q = quantize(3/4) | |
return function (r, w) { | |
for (var i = 0; i < w.data.length; i += 4) { | |
v = q([r.data[i], r.data[i+1], r.data[i+2]]) | |
w.data[i] = (arr(r.data[i]) * v / 255); | |
w.data[i+1] = (gee(r.data[i+1]) * v / 255) ; | |
w.data[i+2] = (bee(r.data[i+2]) * v / 255); | |
w.data[i+3] = 255; | |
} | |
} | |
function quantize(x){ | |
var z = 255 * 3 | |
var q = 255 / x | |
return function(pixels){ | |
var totes = pixels.reduce(function(a, e){ | |
return a + e / 255 | |
},0) | |
return Math.floor(totes * 255 / q) * q | |
} | |
} | |
function quantizeColor(x){ | |
var z = 255 | |
var q = z / x | |
return function(totes){ | |
return Math.floor(totes / q) * q / x / q * 255 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment