0
我无法理解为什么存在差分位移Result。 多边形和文字均匀移动,线条相对误差多边形移位。KineticJS为对象创建坐标
function setNewPosition(x, y) {
var lines = stage.find('Line');
if (lines.length > 0) {
lines.forEach(function inLines(line) {
var points = line.getPoints();
if (points.length > 0) {
points.forEach(function pSet(p) {
p.x += x;
p.y += y;
});
}
});
};
polygons = stage.find('Polygon');
if (polygons.length > 0) {
polygons.forEach(function inPoly(polygon) {
var points = polygon.getPoints();
if (points.length > 0) {
points.forEach(function pSet(p) {
p.x += x;
p.y += y;
});
}
});
};
texts = stage.find('Text');
if (texts.length > 0)
texts.forEach(function inText(text) {
oX = text.getX();
oY = text.getY();
text.setX(oX + x);
text.setY(oY + y);
}
);
layer.draw();
}
_offtopic:这段代码可以得到一些refactoring_;) – c69