• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

eraser with mouse

New Here ,
Apr 06, 2017 Apr 06, 2017

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.

Views

191

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 06, 2017 Apr 06, 2017

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)

Votes

Translate

Translate
Community Expert ,
Apr 06, 2017 Apr 06, 2017

Copy link to clipboard

Copied

LATEST

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines