Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam Harvey
committed
Jan 16, 2010
1 parent
b9af438
commit d3620e2
Showing
7 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* Copyright © 2009-2010 Adam Harvey | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
|
||
/** | ||
* Constructs a greyscale filter. | ||
* | ||
* @class A greyscale filter. | ||
*/ | ||
cinejs.filters.Greyscale = function () { | ||
}; | ||
|
||
/** | ||
* The processing function for the greyscale filter. | ||
* | ||
* @param {ImageData} frame | ||
* @param {HTMLCanvasElement} canvas | ||
*/ | ||
cinejs.filters.Greyscale.prototype.processFrame = function (frame, canvas) { | ||
for (var i = 0; i < frame.data.length; i += 4) { | ||
// Using the algorithm used in libgd. | ||
var value = (0.299 * frame.data[i + 0]) + (0.587 * frame.data[i + 1]) + (0.114 * frame.data[i + 2]); | ||
frame.data[i + 0] = value; | ||
frame.data[i + 1] = value; | ||
frame.data[i + 2] = value; | ||
} | ||
}; | ||
|
||
|
||
cinejs.filters.Grayscale = cinejs.filters.Greyscale; | ||
|
||
|
||
// vim: set cin noet ts=8 sw=8: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Greyscale filter test</title> | ||
<link rel="stylesheet" type="text/css" href="test.css" /> | ||
<script type="text/javascript" src="../dist/cine.js"></script> | ||
<script type="text/javascript" src="test.js"></script> | ||
<script type="text/javascript" src="Greyscale.js"></script> | ||
</head> | ||
<body> | ||
<h1>Greyscale filter test</h1> | ||
|
||
<div id="source-container"> | ||
<h2>Source</h2> | ||
|
||
<video id="source" width="320" height="240"> | ||
<source src="test.ogv" type="video/ogg" /> | ||
<source src="test.mp4" type="video/mp4" /> | ||
</video> | ||
</div> | ||
|
||
<div id="intermediate-container"> | ||
<h2>Intermediate</h2> | ||
|
||
<canvas id="intermediate" width="320" height="240" /> | ||
</div> | ||
|
||
<div id="destination-container"> | ||
<h2>Destination</h2> | ||
|
||
<canvas id="destination" width="320" height="240" /> | ||
</div> | ||
|
||
<a id="play" href="#">Play!</a> | ||
|
||
<span id="fps">?? FPS</span> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* Copyright © 2009-2010 Adam Harvey | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
|
||
window.onload = function () { | ||
cinejs.test(new cinejs.filters.Greyscale()); | ||
}; | ||
|
||
|
||
// vim: set cin noet ts=8 sw=8: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters