moved enhancement parameters into the options array, allows for easy setting on init
This commit is contained in:
parent
293810e050
commit
88b8d57db3
1 changed files with 13 additions and 15 deletions
|
@ -6,6 +6,7 @@
|
||||||
Fo sho:
|
Fo sho:
|
||||||
- page controls
|
- page controls
|
||||||
- chrome frame / ExplorerCanvas
|
- chrome frame / ExplorerCanvas
|
||||||
|
- show loading graphic & then fade in new page if user is ahead of the last loaded page
|
||||||
|
|
||||||
Nice 2 have:
|
Nice 2 have:
|
||||||
- remember position (use localStorage)
|
- remember position (use localStorage)
|
||||||
|
@ -46,7 +47,8 @@ function ComicBook(id, srcs, opts) {
|
||||||
var defaults = {
|
var defaults = {
|
||||||
displayMode: "double", // single / double
|
displayMode: "double", // single / double
|
||||||
zoomMode: "fitWidth", // manual / fitWidth
|
zoomMode: "fitWidth", // manual / fitWidth
|
||||||
manga: false // true / false
|
manga: false, // true / false
|
||||||
|
enhance: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = merge(defaults, opts); // options array for internal use
|
var options = merge(defaults, opts); // options array for internal use
|
||||||
|
@ -61,7 +63,6 @@ function ComicBook(id, srcs, opts) {
|
||||||
var loaded = 0; // the amount of images that have been loaded so far
|
var loaded = 0; // the amount of images that have been loaded so far
|
||||||
|
|
||||||
var scale = 1; // page zoom scale, 1 = 100%
|
var scale = 1; // page zoom scale, 1 = 100%
|
||||||
var enhancements = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Figure out the cursor position relative to the canvas.
|
* Figure out the cursor position relative to the canvas.
|
||||||
|
@ -182,8 +183,6 @@ 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() {
|
||||||
|
|
||||||
|
@ -267,7 +266,7 @@ 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(options.enhance, function(action, options){
|
||||||
ComicBook.prototype.enhance[action](options);
|
ComicBook.prototype.enhance[action](options);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -316,9 +315,9 @@ function ComicBook(id, srcs, opts) {
|
||||||
*/
|
*/
|
||||||
reset: function (method) {
|
reset: function (method) {
|
||||||
if (!method) {
|
if (!method) {
|
||||||
enhancements = {};
|
options.enhance = {};
|
||||||
} else {
|
} else {
|
||||||
delete enhancements[method];
|
delete options.enhance[method];
|
||||||
}
|
}
|
||||||
ComicBook.prototype.drawPage();
|
ComicBook.prototype.drawPage();
|
||||||
},
|
},
|
||||||
|
@ -332,15 +331,15 @@ function ComicBook(id, srcs, opts) {
|
||||||
*
|
*
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
*/
|
*/
|
||||||
brightness: function (options, reset) {
|
brightness: function (params, reset) {
|
||||||
|
|
||||||
if (reset !== false) { this.reset("brightness"); }
|
if (reset !== false) { this.reset("brightness"); }
|
||||||
|
|
||||||
// merge user options with defaults
|
// merge user options with defaults
|
||||||
var opts = merge({ brightness: 0, contrast: 0 }, options);
|
var opts = merge({ brightness: 0, contrast: 0 }, params);
|
||||||
|
|
||||||
// remember options for later
|
// remember options for later
|
||||||
enhancements.brightness = options;
|
options.enhance.brightness = options;
|
||||||
|
|
||||||
// run the enhancement
|
// run the enhancement
|
||||||
Pixastic.process(canvas, "brightness", {
|
Pixastic.process(canvas, "brightness", {
|
||||||
|
@ -356,7 +355,7 @@ function ComicBook(id, srcs, opts) {
|
||||||
* Force black and white
|
* Force black and white
|
||||||
*/
|
*/
|
||||||
desaturate: function () {
|
desaturate: function () {
|
||||||
enhancements.desaturate = {};
|
options.enhance.desaturate = {};
|
||||||
Pixastic.process(canvas, "desaturate", { average : false });
|
Pixastic.process(canvas, "desaturate", { average : false });
|
||||||
init();
|
init();
|
||||||
},
|
},
|
||||||
|
@ -369,9 +368,9 @@ function ComicBook(id, srcs, opts) {
|
||||||
*
|
*
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
*/
|
*/
|
||||||
sharpen: function (options) {
|
sharpen: function (params) {
|
||||||
|
|
||||||
var opts = merge({ amount: 0 }, options);
|
var opts = merge({ amount: 0 }, params);
|
||||||
|
|
||||||
Pixastic.process(canvas, "sharpen", {
|
Pixastic.process(canvas, "sharpen", {
|
||||||
amount: opts.amount
|
amount: opts.amount
|
||||||
|
@ -444,7 +443,6 @@ $(document).ready(function() {
|
||||||
|
|
||||||
book = new ComicBook("comic", pages, options);
|
book = new ComicBook("comic", pages, options);
|
||||||
book.draw();
|
book.draw();
|
||||||
//book.enhance.brightness({ brightness: 100 })
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).resize(function() {
|
$(window).resize(function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue