我使用 paperJS 创建了一个简单的图像标记。现在我必须添加一个撤消选项,以创建我需要存储所有坐标位置和一个要撤消的按钮。我怎么能这样做任何人都可以帮助我。这是我的脚本。
function onMouseDrag(event) {
if(set == 1){
path = new Path.Circle({
center: event.point,
radius: (event.downPoint - event.point).length,
fillColor: null,
strokeColor: '#e9e9ff',
strokeWidth: 1
});
}else if(set == 2){
var rectangle = new Rectangle(event.point, event.downPoint);
var path = new Path.Rectangle(rectangle);
path.fillColor = null;
path.strokeColor = '#e9e9ff';
path.strokeWidth = 1;
}else if(set == 3){
var path = new Path.Line({
from: event.point,
to : event.downPoint,
strokeColor: 'black'
});
}else if(set == 4){
var path = new PointText({
point: event.point,
content: 'The contents of the point text',
fillColor: 'black',
fontSize: 25
});
}
path.removeOnDrag();
};
function onMouseUp(event) {
circles.push(path);
};
这是我的html。
<div class="menu-list">
<input type="button" value="Circle" onClick="return set=1;">
<input type="button" value="Rectangle" onClick="return set=2;">
<input type="button" value="Line" onClick="return set=3;">
<input type="button" value="Text" onClick="return set=4;">
</div>
<div class="img-mark">
<canvas id="canvas" resize></canvas>
</div>
<div class="mark-list">
</div>