在函数参数中将角度设置为零
Set angle to zero in function parameter
此函数来自 CamanJS 库。这是插件的倾斜效果代码
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]);
});
我提供了以下值作为参数。
this.tiltShift(600,400,300,200,0,200,true).render();
但是默认角度还是45度,怎么改?
查看the documentation,具体调用方式为:
tiltShift({ angle: 0 });
方法中对 Util.extend()
的调用创建了一个对象,该对象具有 defaults
的属性,但更改为 opts
中提供的任何值(传递给tiltShift()
)。
此函数来自 CamanJS 库。这是插件的倾斜效果代码
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]);
});
我提供了以下值作为参数。
this.tiltShift(600,400,300,200,0,200,true).render();
但是默认角度还是45度,怎么改?
查看the documentation,具体调用方式为:
tiltShift({ angle: 0 });
方法中对 Util.extend()
的调用创建了一个对象,该对象具有 defaults
的属性,但更改为 opts
中提供的任何值(传递给tiltShift()
)。