starting work on effects
This commit is contained in:
parent
c91827ee03
commit
5dc6f6ae89
3 changed files with 41 additions and 1 deletions
|
@ -243,10 +243,12 @@ function ComicBook(id, srcs, opts) {
|
||||||
page = tmpPage2;
|
page = tmpPage2;
|
||||||
page2 = tmpPage;
|
page2 = tmpPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the page(s)
|
// draw the page(s)
|
||||||
context.drawImage(page, offsetW, offsetH, page_width, page_height);
|
context.drawImage(page, offsetW, offsetH, page_width, page_height);
|
||||||
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); }
|
||||||
|
|
||||||
|
Pixastic.process(canvas, "desaturate", {average : false});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
37
lib/Effects/desaturate.js
Normal file
37
lib/Effects/desaturate.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Pixastic Lib - Desaturation filter - v0.1.1
|
||||||
|
* Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
||||||
|
* License: [http://www.pixastic.com/lib/license.txt]
|
||||||
|
*/
|
||||||
|
|
||||||
|
Pixastic.Actions.desaturate = {
|
||||||
|
|
||||||
|
process : function(params) {
|
||||||
|
var useAverage = !!(params.options.average && params.options.average != "false");
|
||||||
|
|
||||||
|
if (Pixastic.Client.hasCanvasImageData()) {
|
||||||
|
var data = Pixastic.prepareData(params);
|
||||||
|
var rect = params.options.rect;
|
||||||
|
var w = rect.width;
|
||||||
|
var h = rect.height;
|
||||||
|
|
||||||
|
var p = w*h;
|
||||||
|
var pix = p*4, pix1, pix2;
|
||||||
|
|
||||||
|
if (useAverage) {
|
||||||
|
while (p--)
|
||||||
|
data[pix-=4] = data[pix1=pix+1] = data[pix2=pix+2] = (data[pix]+data[pix1]+data[pix2])/3
|
||||||
|
} else {
|
||||||
|
while (p--)
|
||||||
|
data[pix-=4] = data[pix1=pix+1] = data[pix2=pix+2] = (data[pix]*0.3 + data[pix1]*0.59 + data[pix2]*0.11);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (Pixastic.Client.isIE()) {
|
||||||
|
params.image.style.filter += " gray";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
checkSupport : function() {
|
||||||
|
return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE());
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
<link rel="stylesheet" href="styles.css" media="screen, projection" />
|
<link rel="stylesheet" href="styles.css" media="screen, projection" />
|
||||||
|
|
||||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
|
||||||
|
<script src="lib/Effects/desaturate.js"></script>
|
||||||
<script src="lib/ComicBook.js"></script>
|
<script src="lib/ComicBook.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body id="body"">
|
<body id="body"">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue