From 4bd53e69ea016d30147d6cb4c84ae264ab819b55 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 15 Jul 2015 19:56:39 -0400 Subject: renaming MircColor/color_code.js to photo.js --- grid5.html | 30 +++--- image.html | 24 ++--- js/clipboard.js | 10 ++ js/color_code.js | 280 ------------------------------------------------------- js/photo.js | 280 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ webcam.html | 12 +-- 6 files changed, 323 insertions(+), 313 deletions(-) delete mode 100644 js/color_code.js create mode 100644 js/photo.js diff --git a/grid5.html b/grid5.html index ae0929f..65b1412 100644 --- a/grid5.html +++ b/grid5.html @@ -38,8 +38,8 @@ var canvas = new Matrix ( grid_w * 16, grid_h * 16, function(x,y){ var opacity = (x % grid_w) / (grid_w-2) if ( (x % grid_w) != grid_w-gap && (y % grid_h) != grid_h-gap) { - var a = MircColor.colors[ all_hue(i) ] - var b = MircColor.colors[ all_hue(j) ] + var a = Photo.colors[ all_hue(i) ] + var b = Photo.colors[ all_hue(j) ] var a0 = a[0]/255 * opacity var a1 = a[1]/255 * opacity @@ -53,7 +53,7 @@ var canvas = new Matrix ( grid_w * 16, grid_h * 16, function(x,y){ pixel[1] = clamp( a1 + b1, 0, 1 ) * 255 pixel[2] = clamp( a2 + b2, 0, 1 ) * 255 - lex.fg = lex.bg = MircColor.closest_to(pixel) + lex.fg = lex.bg = Photo.closest_to(pixel) lex.char = " " } else if ((y % grid_h) == grid_h-gap) { @@ -82,12 +82,12 @@ var canvas = new Matrix ( grid_w * 16, grid_h * 16, function(x,y){ var j = floor(y / grid_h) if ( (x % grid_w) != grid_w-gap && (y % grid_h) != grid_h-gap) { - var a = MircColor.colors[ all_hue(i) ] - var b = MircColor.colors[ all_hue(j) ] + var a = Photo.colors[ all_hue(i) ] + var b = Photo.colors[ all_hue(j) ] pixel[0] = clamp( a[0]/255 * b[0]/255, 0, 1 ) * 255 pixel[1] = clamp( a[1]/255 * b[1]/255, 0, 1 ) * 255 pixel[2] = clamp( a[2]/255 * b[2]/255, 0, 1 ) * 255 - lex.fg = lex.bg = MircColor.closest_to(pixel) + lex.fg = lex.bg = Photo.closest_to(pixel) lex.char = " " } else if ((y % grid_h) == grid_h-gap) { @@ -113,12 +113,12 @@ var canvas = new Matrix ( grid_w * 16, grid_h * 16, function(x,y){ var j = floor(y / grid_h) if ( (x % grid_w) != grid_w-gap && (y % grid_h) != grid_h-gap) { - var a = MircColor.colors[ all_hue(i) ] - var b = MircColor.colors[ all_hue(j) ] + var a = Photo.colors[ all_hue(i) ] + var b = Photo.colors[ all_hue(j) ] pixel[0] = clamp( 1 - (1-a[0]/255) * (1-b[0]/255), 0, 1 ) * 255 pixel[1] = clamp( 1 - (1-a[1]/255) * (1-b[1]/255), 0, 1 ) * 255 pixel[2] = clamp( 1 - (1-a[2]/255) * (1-b[2]/255), 0, 1 ) * 255 - lex.fg = lex.bg = MircColor.closest_to(pixel) + lex.fg = lex.bg = Photo.closest_to(pixel) lex.char = " " } else if ((y % grid_h) == grid_h-gap) { @@ -146,8 +146,8 @@ var canvas = new Matrix ( grid_w * 16, grid_h * 16, function(x,y){ var j = floor(y / grid_h) if ( (x % grid_w) != grid_w-gap && (y % grid_h) != grid_h-gap) { - var a = MircColor.colors[ all_hue(i) ] - var b = MircColor.colors[ all_hue(j) ] + var a = Photo.colors[ all_hue(i) ] + var b = Photo.colors[ all_hue(j) ] var a0 = a[0]/255 var a1 = a[1]/255 @@ -168,7 +168,7 @@ var canvas = new Matrix ( grid_w * 16, grid_h * 16, function(x,y){ pixel[1] = clamp( 1 - 2 * (1-a1) * (1-b1), 0, 1 ) * 255 pixel[2] = clamp( 1 - 2 * (1-a2) * (1-b2), 0, 1 ) * 255 } - lex.fg = lex.bg = MircColor.closest_to(pixel) + lex.fg = lex.bg = Photo.closest_to(pixel) lex.char = " " } else if ((y % grid_h) == grid_h-gap) { @@ -197,8 +197,8 @@ var canvas = new Matrix ( grid_w * 16, grid_h * 16, function(x,y){ var j = floor(y / grid_h) if ( (x % grid_w) != grid_w-gap && (y % grid_h) != grid_h-gap) { - var a = MircColor.colors[ all_hue(i) ] - var b = MircColor.colors[ all_hue(j) ] + var a = Photo.colors[ all_hue(i) ] + var b = Photo.colors[ all_hue(j) ] var a0 = a[0]/255 var a1 = a[1]/255 @@ -229,7 +229,7 @@ var canvas = new Matrix ( grid_w * 16, grid_h * 16, function(x,y){ pixel[2] = clamp( 1 - 2 * (1-a2) * (1-b2), 0, 1 ) * 255 } - lex.fg = lex.bg = MircColor.closest_to(pixel) + lex.fg = lex.bg = Photo.closest_to(pixel) lex.char = " " } else if ((y % grid_h) == grid_h-gap) { diff --git a/image.html b/image.html index 347a818..7bcf645 100644 --- a/image.html +++ b/image.html @@ -47,7 +47,7 @@ var nn = $(nn_el).prop('checked') var invert = $(invert_el).prop('checked') var width_timeout -MircColor.set_recolor_fn(function(rgb){ +Photo.set_recolor_fn(function(rgb){ if (invert) { rgb[0] = 255 - rgb[0] rgb[1] = 255 - rgb[1] @@ -67,25 +67,25 @@ listen(lum_el, window, "lum") -MircColor.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) +Photo.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) url_el.addEventListener('change', function(){ ratio_el.value = ratio = 0 url = "/cgi-bin/proxy?" + url_el.value - MircColor.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) + Photo.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) }) nn_el.addEventListener('change', function(){ nn = $(nn_el).prop('checked') - MircColor.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) + Photo.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) }) invert_el.addEventListener('change', function(){ invert = $(invert_el).prop('checked') - MircColor.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) + Photo.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) }) palette_el.addEventListener('change', function(){ var palette = $(palette_el).val() - MircColor.set_colors( MircColor[palette] ) - MircColor.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) + Photo.set_colors( Photo[palette] ) + Photo.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) }) ratio_el.addEventListener("input", function(){ ratio = parseFloat( ratio_el.value ) @@ -94,7 +94,7 @@ ratio_el.addEventListener("input", function(){ height_span.innerHTML = "..." clearTimeout( width_timeout ) width_timeout = setTimeout(function(){ - MircColor.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) + Photo.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) }, 50) }) width_el.addEventListener("input", function(){ @@ -103,19 +103,19 @@ width_el.addEventListener("input", function(){ height_span.innerHTML = "..." clearTimeout( width_timeout ) width_timeout = setTimeout(function(){ - MircColor.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) + Photo.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) }, 50) }) function listen (el, obj, val) { el.addEventListener("input", function(){ obj[val] = parseFloat( el.value ) - MircColor.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) + Photo.fromUrl(url, toCanvas, { width: width, ratio: ratio, neighbor: nn }) }) } function toCanvas(rows){ var wpx = 6, hpx = 12 var canvas = document.createElement("canvas"), ctx = canvas.getContext('2d') - var rgb_colors = MircColor.colors.map(function(c){ return "rgb(" + c + ")" }) + var rgb_colors = Photo.colors.map(function(c){ return "rgb(" + c + ")" }) canvas.width = rows[0].length * wpx canvas.height = rows.length * hpx rows.forEach(function(row, j){ @@ -127,7 +127,7 @@ function toCanvas(rows){ height_span.innerHTML = rows.length image_style.innerHTML = "" image_style.appendChild(canvas) - text_style.value = MircColor.ascii(rows) + text_style.value = Photo.ascii(rows) } diff --git a/js/clipboard.js b/js/clipboard.js index bcbfdff..b8b583e 100644 --- a/js/clipboard.js +++ b/js/clipboard.js @@ -205,6 +205,16 @@ var clipboard = (function () { clipboard.focus() return output }, + + export_png: function () { + var palette = 'mirc' + var font = 'fixedsys' + + var start = Date.now(); + colorcode.to_canvas(in_text.value, {canvas:canvas, palette:palette, font:font}) + var total = Date.now() - start; + console.log("took " + total) + } } diff --git a/js/color_code.js b/js/color_code.js deleted file mode 100644 index 7811d82..0000000 --- a/js/color_code.js +++ /dev/null @@ -1,280 +0,0 @@ - -var MircColor = (function(){ - var COLORS = [ - [255,255,255], - [0,0,0], - [0,0,127], - [0,147,0], - [255,0,0], - [127,0,0], - [156,0,156], - [252,127,0], - [255,255,0], - [0,252,0], - [0,147,147], - [0,255,255], - [0,0,252], - [255,0,255], - [127,127,127], - [210,210,210] - ] - var HUES = [ - [255,255,255], - [0,0,0], - [0,0,127], - [0,147,0], - [255,0,0], - [127,0,0], - [156,0,156], - [252,127,0], - [255,255,0], - [0,252,0], - [0,147,147], - [0,255,255], - [0,0,252], - [255,0,255], - null, - null, - ] - var GRAYS = [ - [255,255,255], - [0,0,0], - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - [127,127,127], - [210,210,210] - ] - var REDS = [ - [255,255,255], - [0,0,0], - null, - null, - [255,0,0], - [127,0,0], - null, - [252,127,0], - [255,255,0], - null, - null, - null, - null, - [255,0,255], - null, - null, - ] - var YELLOWS = [ - [255,255,255], - [0,0,0], - null, - [0,147,0], - null, - null, - null, - [252,127,0], - [255,255,0], - [0,252,0], - null, - [0,255,255], - null, - null, - null, - null, - ] - var BLUES = [ - [255,255,255], - [0,0,0], - [0,0,127], - null, - null, - null, - [156,0,156], - null, - null, - [0,252,0], - [0,147,147], - [0,255,255], - [0,0,252], - [255,0,255], - null, - null, - ] - var colors = COLORS, recolor_fn = null - var canvas = document.createElement("canvas"), ctx = canvas.getContext('2d'), pixels - - function set_colors (a) { - colors = a - } - function set_recolor_fn (fn) { - recolor_fn = fn - } - - function closest_to(pixel){ - if (recolor_fn) { - pixel = recolor_fn(pixel) - } - return colors.reduce(function(prev, curr, index) { - var d = distance(pixel, curr) - if (prev[0] > d) { - prev[0] = d - prev[1] = index - } - return prev - }, [Infinity, -1])[1] - } - - function distance(u, v){ - if (! v) return Math.Infinity - var r = u[0] - v[0] - var g = u[1] - v[1] - var b = u[2] - v[2] - return Math.sqrt(r*r+g*g+b*b) - } - - function fromImageData (pixels, cb){ - var rows = [], - pixel = new Array (4), - data = pixels.data, - t - for (var i = 0, h = pixels.height; i < h; i++) { - var row = [] - rows.push(row) - for (var j = 0, w = pixels.width; j < w; j++) { - t = (i*w+j)*4 - pixel[0] = data[t] - pixel[1] = data[t+1] - pixel[2] = data[t+2] - pixel[3] = data[t+3] - row[j] = closest_to(pixel) - } - } - if (! cb) return rows - else cb (rows) - } - - function getNaturalDimensions (img) { - if (img.naturalWidth) { - return { naturalWidth: img.naturalWidth, naturalHeight: img.naturalHeight } - } - if (img.videoWidth) { - return { naturalWidth: img.videoWidth, naturalHeight: img.videoHeight } - } - return { naturalWidth: img.width, naturalHeight: img.height } - } - function neighbor (canvas, ctx, img) { - var dims = getNaturalDimensions(img) - var scratch = document.createElement("canvas") - var scratchCtx = scratch.getContext('2d') - scratch.width = dims.naturalWidth - scratch.height = dims.naturalHeight - scratchCtx.drawImage(img, 0, 0, dims.naturalWidth, dims.naturalHeight) - var srcImageData = scratchCtx.getImageData(0,0,scratch.width,scratch.height) - var destImageData = ctx.createImageData(canvas.width,canvas.height) - var src = srcImageData.data, dest = destImageData.data - var dt, dw = destImageData.width, dh = destImageData.height - var st, sw = srcImageData.width, sh = srcImageData.height - for (var i = 0; i < dh; i++) { - for (var j = 0; j < dw; j++) { - var y = i * sh/dh - var x = j * sw/dw - dt = ((i*dw) + j) * 4 - st = Math.floor( Math.floor(y)*sw + x ) * 4 - dest[dt] = src[st] - dest[dt+1] = src[st+1] - dest[dt+2] = src[st+2] - dest[dt+3] = src[st+3] - } - } - return destImageData - } - var img = new Image () - function fromUrl (url, cb, opt) { - img.onload = function(){ - fromCanvas(img, cb, opt) - } - if (img.src == url) { return img.onload() } - img.src = url - if (img.complete) { return img.onload() } - } - function fromCanvas (img, cb, opt) { - var dims = getNaturalDimensions(img) - if (opt.width) { - canvas.width = opt.width - if (opt.height) { - canvas.height = opt.height - } else if (opt.ratio) { - canvas.height = opt.width / opt.ratio - } else { - canvas.height = (dims.naturalHeight * width / dims.naturalWidth) / 2 - } - } - else { - canvas.width = dims.naturalWidth * 2 - canvas.height = dims.naturalHeight - } - if (opt.neighbor) { - pixels = neighbor(canvas, ctx, img) - } - else { - ctx.drawImage(img,0,0,dims.naturalWidth,dims.naturalHeight,0,0,canvas.width,canvas.height) - pixels = ctx.getImageData(0,0,canvas.width,canvas.height) - } - fromImageData(pixels, cb) - } - function ascii (rows) { - var lines = rows.map(function(str){ - var last = -1 - return str.map(function(index){ - if (last == index) return " " - last = index - return "\\x031," + index + " " - }).join("") - }).join("\\n") - var txt = '/exec -out printf "' + lines + '"\n' - return txt - } - function asciiFromUrl (url, cb, opt) { - fromUrl(url, function(rows){ - cb(ascii(rows), rows) - }, width) - } - function stringFromUrl (url, cb, opt) { - fromUrl(url, function(rows){ - cb(rows.map(function(str){ - return str.map(function(index){ return "\C-c1," + index + " " }).join("") - }).join("\n")) - }, width) - } - - return { - colors: COLORS, - hues: HUES, - grays: GRAYS, - reds: REDS, - yellows: YELLOWS, - blues: BLUES, - set_recolor_fn: set_recolor_fn, - set_colors: set_colors, - closest_to: closest_to, - distance: distance, - fromUrl: fromUrl, - fromCanvas: fromCanvas, - fromImageData: fromImageData, - stringFromUrl: stringFromUrl, - asciiFromUrl: asciiFromUrl, - ascii: ascii, - neighbor: neighbor, - } - -})() - - diff --git a/js/photo.js b/js/photo.js new file mode 100644 index 0000000..e1b8079 --- /dev/null +++ b/js/photo.js @@ -0,0 +1,280 @@ + +var Photo = (function(){ + var COLORS = [ + [255,255,255], + [0,0,0], + [0,0,127], + [0,147,0], + [255,0,0], + [127,0,0], + [156,0,156], + [252,127,0], + [255,255,0], + [0,252,0], + [0,147,147], + [0,255,255], + [0,0,252], + [255,0,255], + [127,127,127], + [210,210,210] + ] + var HUES = [ + [255,255,255], + [0,0,0], + [0,0,127], + [0,147,0], + [255,0,0], + [127,0,0], + [156,0,156], + [252,127,0], + [255,255,0], + [0,252,0], + [0,147,147], + [0,255,255], + [0,0,252], + [255,0,255], + null, + null, + ] + var GRAYS = [ + [255,255,255], + [0,0,0], + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + [127,127,127], + [210,210,210] + ] + var REDS = [ + [255,255,255], + [0,0,0], + null, + null, + [255,0,0], + [127,0,0], + null, + [252,127,0], + [255,255,0], + null, + null, + null, + null, + [255,0,255], + null, + null, + ] + var YELLOWS = [ + [255,255,255], + [0,0,0], + null, + [0,147,0], + null, + null, + null, + [252,127,0], + [255,255,0], + [0,252,0], + null, + [0,255,255], + null, + null, + null, + null, + ] + var BLUES = [ + [255,255,255], + [0,0,0], + [0,0,127], + null, + null, + null, + [156,0,156], + null, + null, + [0,252,0], + [0,147,147], + [0,255,255], + [0,0,252], + [255,0,255], + null, + null, + ] + var colors = COLORS, recolor_fn = null + var canvas = document.createElement("canvas"), ctx = canvas.getContext('2d'), pixels + + function set_colors (a) { + colors = a + } + function set_recolor_fn (fn) { + recolor_fn = fn + } + + function closest_to(pixel){ + if (recolor_fn) { + pixel = recolor_fn(pixel) + } + return colors.reduce(function(prev, curr, index) { + var d = distance(pixel, curr) + if (prev[0] > d) { + prev[0] = d + prev[1] = index + } + return prev + }, [Infinity, -1])[1] + } + + function distance(u, v){ + if (! v) return Math.Infinity + var r = u[0] - v[0] + var g = u[1] - v[1] + var b = u[2] - v[2] + return Math.sqrt(r*r+g*g+b*b) + } + + function fromImageData (pixels, cb){ + var rows = [], + pixel = new Array (4), + data = pixels.data, + t + for (var i = 0, h = pixels.height; i < h; i++) { + var row = [] + rows.push(row) + for (var j = 0, w = pixels.width; j < w; j++) { + t = (i*w+j)*4 + pixel[0] = data[t] + pixel[1] = data[t+1] + pixel[2] = data[t+2] + pixel[3] = data[t+3] + row[j] = closest_to(pixel) + } + } + if (! cb) return rows + else cb (rows) + } + + function getNaturalDimensions (img) { + if (img.naturalWidth) { + return { naturalWidth: img.naturalWidth, naturalHeight: img.naturalHeight } + } + if (img.videoWidth) { + return { naturalWidth: img.videoWidth, naturalHeight: img.videoHeight } + } + return { naturalWidth: img.width, naturalHeight: img.height } + } + function neighbor (canvas, ctx, img) { + var dims = getNaturalDimensions(img) + var scratch = document.createElement("canvas") + var scratchCtx = scratch.getContext('2d') + scratch.width = dims.naturalWidth + scratch.height = dims.naturalHeight + scratchCtx.drawImage(img, 0, 0, dims.naturalWidth, dims.naturalHeight) + var srcImageData = scratchCtx.getImageData(0,0,scratch.width,scratch.height) + var destImageData = ctx.createImageData(canvas.width,canvas.height) + var src = srcImageData.data, dest = destImageData.data + var dt, dw = destImageData.width, dh = destImageData.height + var st, sw = srcImageData.width, sh = srcImageData.height + for (var i = 0; i < dh; i++) { + for (var j = 0; j < dw; j++) { + var y = i * sh/dh + var x = j * sw/dw + dt = ((i*dw) + j) * 4 + st = Math.floor( Math.floor(y)*sw + x ) * 4 + dest[dt] = src[st] + dest[dt+1] = src[st+1] + dest[dt+2] = src[st+2] + dest[dt+3] = src[st+3] + } + } + return destImageData + } + var img = new Image () + function fromUrl (url, cb, opt) { + img.onload = function(){ + fromCanvas(img, cb, opt) + } + if (img.src == url) { return img.onload() } + img.src = url + if (img.complete) { return img.onload() } + } + function fromCanvas (img, cb, opt) { + var dims = getNaturalDimensions(img) + if (opt.width) { + canvas.width = opt.width + if (opt.height) { + canvas.height = opt.height + } else if (opt.ratio) { + canvas.height = opt.width / opt.ratio + } else { + canvas.height = (dims.naturalHeight * width / dims.naturalWidth) / 2 + } + } + else { + canvas.width = dims.naturalWidth * 2 + canvas.height = dims.naturalHeight + } + if (opt.neighbor) { + pixels = neighbor(canvas, ctx, img) + } + else { + ctx.drawImage(img,0,0,dims.naturalWidth,dims.naturalHeight,0,0,canvas.width,canvas.height) + pixels = ctx.getImageData(0,0,canvas.width,canvas.height) + } + fromImageData(pixels, cb) + } + function ascii (rows) { + var lines = rows.map(function(str){ + var last = -1 + return str.map(function(index){ + if (last == index) return " " + last = index + return "\\x031," + index + " " + }).join("") + }).join("\\n") + var txt = '/exec -out printf "' + lines + '"\n' + return txt + } + function asciiFromUrl (url, cb, opt) { + fromUrl(url, function(rows){ + cb(ascii(rows), rows) + }, width) + } + function stringFromUrl (url, cb, opt) { + fromUrl(url, function(rows){ + cb(rows.map(function(str){ + return str.map(function(index){ return "\C-c1," + index + " " }).join("") + }).join("\n")) + }, width) + } + + return { + colors: COLORS, + hues: HUES, + grays: GRAYS, + reds: REDS, + yellows: YELLOWS, + blues: BLUES, + set_recolor_fn: set_recolor_fn, + set_colors: set_colors, + closest_to: closest_to, + distance: distance, + fromUrl: fromUrl, + fromCanvas: fromCanvas, + fromImageData: fromImageData, + stringFromUrl: stringFromUrl, + asciiFromUrl: asciiFromUrl, + ascii: ascii, + neighbor: neighbor, + } + +})() + + diff --git a/webcam.html b/webcam.html index 5b40d6e..9d92931 100644 --- a/webcam.html +++ b/webcam.html @@ -77,10 +77,10 @@ getStream(function(video){ function animate () { requestAnimationFrame(animate) if (! camera.videoWidth) return - MircColor.fromCanvas(camera, toCanvas, { width: width, ratio: ratio, neighbor: nn }) + Photo.fromCanvas(camera, toCanvas, { width: width, ratio: ratio, neighbor: nn }) } -MircColor.set_recolor_fn(function(rgb){ +Photo.set_recolor_fn(function(rgb){ var hsl = rgb2hsl(rgb) hsl[0] = mod(hsl[0] + hue, 1.0) hsl[1] = clamp(hsl[1] + sat, 0.0, 1.0) @@ -107,9 +107,9 @@ listen(quant_el, window, "quant") save_el.addEventListener('click', save) function save (){ - MircColor.fromCanvas(camera, saveText, { width: width, ratio: ratio, neighbor: nn }) + Photo.fromCanvas(camera, saveText, { width: width, ratio: ratio, neighbor: nn }) function saveText(rows) { - text_style.value = MircColor.ascii(rows) + text_style.value = Photo.ascii(rows) if (window.self !== window.top) { window.parent.postMessage(text_style.value, "*"); } @@ -123,7 +123,7 @@ invert_el.addEventListener('change', function(){ }) palette_el.addEventListener('change', function(){ var palette = $(palette_el).val() - MircColor.set_colors( MircColor[palette] ) + Photo.set_colors( Photo[palette] ) }) ratio_el.addEventListener("input", function(){ ratio = parseFloat( ratio_el.value ) @@ -144,7 +144,7 @@ function listen (el, obj, val) { var canvas = document.createElement("canvas"), ctx = canvas.getContext('2d') function toCanvas(rows){ var wpx = 6, hpx = 12 - var rgb_colors = MircColor.colors.map(function(c){ return "rgb(" + c + ")" }) + var rgb_colors = Photo.colors.map(function(c){ return "rgb(" + c + ")" }) canvas.width = rows[0].length * wpx canvas.height = rows.length * hpx rows.forEach(function(row, j){ -- cgit v1.2.3-70-g09d2