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 change angle for tiltshift effect? #171

Closed 9itish closed 9 years ago

9itish commented 9 years ago

I tried to change angle of tiltshift but could not. This was the code

 Caman.Filter.register("tiltShift", function(opts) {
 var defaults, gradient;

defaults = {
center: {
  x: this.dimensions.width / 2,
  y: this.dimensions.height / 2
},
angle: 45,
focusWidth: 200,
startRadius: 3,
radiusFactor: 1.5,
steps: 3
};
opts = Util.extend(defaults, opts);
opts.angle *= Math.PI / 180;
gradient = getLinearGradientMap(this.dimensions.width, this.dimensions.height, opts.center.x,  opts.center.y, opts.angle, opts.focusWidth, true);
return this.processPlugin("compoundBlur", [gradient, opts.startRadius, opts.radiusFactor, opts.steps]);
 });

I passed this.tiltShift(600,400,300,200,0,200,true).render(); but none of the defaults changes. What is the correct way to pass parameters.

meltingice commented 9 years ago

The parameters are passed as an object. See the defaults object in the plugin for everything you can change.

this.tiltShift({angle: 95, startRadius: 200});