enhancements: added saturate method to undo a desaturate, tweaked the reset method to allow for resetting one method at a time, all methods now reset their own state before applying
This commit is contained in:
parent
df474ec5ec
commit
85e5244d8d
1 changed files with 30 additions and 9 deletions
|
@ -181,9 +181,11 @@ function ComicBook(id, srcs, opts) {
|
||||||
*
|
*
|
||||||
* TODO: break this down into drawSinglePage() & drawDoublePage()?
|
* TODO: break this down into drawSinglePage() & drawDoublePage()?
|
||||||
* TODO: if the current browser doesn't have canvas support, use img tags
|
* 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 zoom_scale;
|
||||||
var offsetW = 0, offsetH = 0;
|
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); }
|
if (options.displayMode === "double" && typeof page2 === "object") { context.drawImage(page2, page_width + offsetW, offsetH, page_width, page_height); }
|
||||||
|
|
||||||
// apply any image enhancements previously defined
|
// apply any image enhancements previously defined
|
||||||
$.each(enhancements, function(action, options) {
|
$.each(enhancements, function(action, options){
|
||||||
ComicBook.prototype.enhance[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/
|
* Powered by the awesome Pixastic: http://www.pixastic.com/
|
||||||
*
|
*
|
||||||
* TODO: reset & apply all image enhancements each time before applying new one
|
* TODO: reset & apply all image enhancements each time before applying new one
|
||||||
|
*
|
||||||
* TODO: abstract this into an "Enhance" object, separate from ComicBook?
|
* TODO: abstract this into an "Enhance" object, separate from ComicBook?
|
||||||
*/
|
*/
|
||||||
ComicBook.prototype.enhance = {
|
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 () {
|
reset: function (method) {
|
||||||
enhancements = {};
|
if (!method) {
|
||||||
|
enhancements = {};
|
||||||
|
} else {
|
||||||
|
delete enhancements[method];
|
||||||
|
}
|
||||||
ComicBook.prototype.drawPage();
|
ComicBook.prototype.drawPage();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -320,7 +331,9 @@ function ComicBook(id, srcs, opts) {
|
||||||
*
|
*
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
*/
|
*/
|
||||||
brightness: function (options) {
|
brightness: function (options, reset) {
|
||||||
|
|
||||||
|
if (reset !== false) this.reset("brightness");
|
||||||
|
|
||||||
// merge user options with defaults
|
// merge user options with defaults
|
||||||
var options = merge({ brightness: 0, contrast: 0 }, options);
|
var options = merge({ brightness: 0, contrast: 0 }, options);
|
||||||
|
@ -341,12 +354,20 @@ function ComicBook(id, srcs, opts) {
|
||||||
/**
|
/**
|
||||||
* Force black and white
|
* Force black and white
|
||||||
*/
|
*/
|
||||||
desaturate: function () {
|
desaturate: function () {
|
||||||
enhancements.desaturate = {};
|
enhancements.desaturate = {};
|
||||||
Pixastic.process(canvas, "desaturate", { average : false });
|
Pixastic.process(canvas, "desaturate", { average : false });
|
||||||
init();
|
init();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undo desaturate
|
||||||
|
*/
|
||||||
|
saturate: function () {
|
||||||
|
delete enhancements.desaturate;
|
||||||
|
ComicBook.prototype.drawPage();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sharpen
|
* Sharpen
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue