meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.56k stars 406 forks source link

Apply to all images with a particular class? #84

Closed RevConcept closed 11 years ago

RevConcept commented 11 years ago

Is something like this possible? It's only effecting the first image on may page:

Caman("a.work img", function () { this.brightness(10); this.contrast(30); this.sepia(60); this.saturation(-30); this.render(); });

Thanks!

meltingice commented 11 years ago

Unfortunately Caman can only handle a single image per instance at a time right now. It's definitely on the roadmap to handle exactly what you described.

There are some easy ways around this luckily. You should be able to do something like this:

var filterFunc = function () {
  this.brightness(10);
  this.contrast(30);
  this.sepia(60);
  this.saturation(-30);
  this.render();
};

$("a.work img").each(function () {
  Caman($(this).get(0), filterFunc);
});
RevConcept commented 11 years ago

Thanks...works great!