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,6 +181,8 @@ 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() {
|
||||
|
||||
|
@ -265,7 +267,7 @@ function ComicBook(id, srcs, opts) {
|
|||
|
||||
// apply any image enhancements previously defined
|
||||
$.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/
|
||||
*
|
||||
* 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 () {
|
||||
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);
|
||||
|
@ -347,6 +360,14 @@ function ComicBook(id, srcs, opts) {
|
|||
init();
|
||||
},
|
||||
|
||||
/**
|
||||
* Undo desaturate
|
||||
*/
|
||||
saturate: function () {
|
||||
delete enhancements.desaturate;
|
||||
ComicBook.prototype.drawPage();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sharpen
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue