meltingice / CamanJS

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

How to Use Caman.Convert #216

Open Seikon opened 7 years ago

Seikon commented 7 years ago

Hi!

I am trying to convert an image from rgb to hsv using Caman.Convert, but i don't find enough documentation how to use it and import the needed modules.

Can anyone show an example of how to use Caman.Convert?

Thank you.

flashpuller commented 6 years ago

Seems developers forgot to add Caman.Convert declaration in their code, so it should look like Caman.Convert =Convert = (function() {.....

then something like

Caman = require('caman.full.js').Caman;
Convert = Caman.Convert;

Caman.Filter.register('someFilter', function () {
    this.process('someFilter', function (rgba) {
            var hsv = Convert.rgbToHSV(rgba.r, rgba.g, rgba.b);
            var out= Convert.hsvToRGB(hsv.h, hsv.s, hsv.v);
        }
        // Return the modified RGB values
        return out;
    });
});