0

This function is from CamanJS library. This is the code for tiltshift effect of plugin

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 supplied the following values as parameters.

this.tiltShift(600,400,300,200,0,200,true).render();

But the default angle is still 45. How do I change it?

4

1 回答 1

0

查看文档,调用它的具体方法是:

tiltShift({ angle: 0 }); 

方法中的调用Util.extend()会创建一个具有 的属性的对象,但会更改为在(传递给的对象)defaults中提供的任何值。optstiltShift()

于 2015-04-13T06:46:13.457 回答