diff --git a/lib/ComicBook.js b/lib/ComicBook.js index 772ab18..a8ae674 100644 --- a/lib/ComicBook.js +++ b/lib/ComicBook.js @@ -181,9 +181,11 @@ function ComicBook(id, srcs, opts) { * * TODO: break this down into drawSinglePage() & drawDoublePage()? * TODO: if the current browser doesn't have canvas support, use img tags + * + * @param applyEnhancements {boolean} */ - ComicBook.prototype.drawPage = function () { - + ComicBook.prototype.drawPage = function() { + var zoom_scale; var offsetW = 0, offsetH = 0; @@ -264,8 +266,8 @@ function ComicBook(id, srcs, opts) { if (options.displayMode === "double" && typeof page2 === "object") { context.drawImage(page2, page_width + offsetW, offsetH, page_width, page_height); } // apply any image enhancements previously defined - $.each(enhancements, function(action, options) { - ComicBook.prototype.enhance[action](options); + $.each(enhancements, function(action, options){ + ComicBook.prototype.enhance[action](options, false); }); }; @@ -299,15 +301,24 @@ function ComicBook(id, srcs, opts) { * Powered by the awesome Pixastic: http://www.pixastic.com/ * * TODO: reset & apply all image enhancements each time before applying new one + * * TODO: abstract this into an "Enhance" object, separate from ComicBook? */ ComicBook.prototype.enhance = { /** - * Render the page with no enhancements + * Reset enhancements. + * This can reset a specific enhancement if the method name is passed, or + * it will reset all. + * + * @param method {string} the specific enhancement to reset */ - reset: function () { - enhancements = {}; + reset: function (method) { + if (!method) { + enhancements = {}; + } else { + delete enhancements[method]; + } ComicBook.prototype.drawPage(); }, @@ -320,7 +331,9 @@ function ComicBook(id, srcs, opts) { * * @param {Object} options */ - brightness: function (options) { + brightness: function (options, reset) { + + if (reset !== false) this.reset("brightness"); // merge user options with defaults var options = merge({ brightness: 0, contrast: 0 }, options); @@ -341,12 +354,20 @@ function ComicBook(id, srcs, opts) { /** * Force black and white */ - desaturate: function () { + desaturate: function () { enhancements.desaturate = {}; Pixastic.process(canvas, "desaturate", { average : false }); init(); }, + /** + * Undo desaturate + */ + saturate: function () { + delete enhancements.desaturate; + ComicBook.prototype.drawPage(); + }, + /** * Sharpen *