Skip to content

Instantly share code, notes, and snippets.

@meltingice
Created March 23, 2012 14:53
Show Gist options
  • Save meltingice/2171421 to your computer and use it in GitHub Desktop.
Save meltingice/2171421 to your computer and use it in GitHub Desktop.
CamanJS Example
// 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();
});
};
@bebraw
Copy link

bebraw commented Sep 5, 2013

Quick note: the API isn't async anymore! Better use caman.revert(false);.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment