Copy link to clipboard
Copied
var shape, oldX, oldY, size, color;
shape = new createjs.Shape();
stage.on("stagemousemove", function (evt) {
if (oldX) {
shape.graphics.beginStroke(color)
.setStrokeStyle(size, "round")
.moveTo(oldX, oldY)
.lineTo(evt.stageX, evt.stageY);
stage.update();
}
oldX = evt.stageX;
oldY = evt.stageY;
stage.update();
})
stage.on("stagemouseup", function (event) {
color = createjs.Graphics.getRGB(50, 100, 150, 1);
});
stage.on("stagemousedown", function (event) {
color = createjs.Graphics.getRGB(50, 100, 150, 1);
size = 4;
});
stage.on("stagemouseup", function (event) {
color = "";
});
stage.addChild(shape);
stage.update();
_______________________________________________________________
My english is not very good soryy.
I can not delete this code with the mouse, please help me.
if you want to (make it appear as if you) 'erase', use the color of the stage. generally, you also would increase the stroke size when erasing.
p.s. it looks like you probably want to use if(color), not if(oldX)
Copy link to clipboard
Copied
if you want to (make it appear as if you) 'erase', use the color of the stage. generally, you also would increase the stroke size when erasing.
p.s. it looks like you probably want to use if(color), not if(oldX)