[英]KineticJS: How do I Crop an Image?
I use KineticJs and want to crop an existing image. 我使用KineticJs,希望裁剪现有图像。 I tried the following: 我尝试了以下方法:
var image = new Kinetic.Image({}); // some kinetic image
var layer = new Kinetic.Layer();
var stage = new Kinetic.Stage({
container: "iPhone",
width: 1000,
height: 1000
});
image.crop({
x: 0,
y : 0,
width : 100,
height : 100
});
image = image.crop();
layer.add(image);
layer.draw();
stage.add(layer);
The former does not work. 前者不起作用。 How do I crop an existing image with KineticJs? 如何使用KineticJs裁剪现有图像?
You should pass javascript object with x
, y
, width
and height
properties to crop function: 您应该将具有x
, y
, width
和height
属性的javascript对象传递给裁剪函数:
image.crop({
x: 10,
y : 10,
width : 66,
height : 60
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.