Created
March 23, 2012 14:53
-
-
Save meltingice/2171421 to your computer and use it in GitHub Desktop.
CamanJS Example
This file contains hidden or 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
// First, initialize Caman (only do this once) | |
caman = Caman("#image-id"); | |
// This will be called when a slider is adjusted | |
var applyFilters = function () { | |
// Revert the canvas to its original state. This is asynchronous. | |
caman.revert(function () { | |
// Once canvas is ready, go through each slider and call filter | |
var slider; | |
for (var key in sliders) { | |
slider = sliders[key]; | |
// Call the caman filter with the slider value | |
caman[slider.filter](slider.value); | |
} | |
// Once Caman knows all the filters and their adjustment values, | |
// we can render the canvas. | |
caman.render(); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick note: the API isn't async anymore! Better use
caman.revert(false);
.