Stopping the drag with the pen effect

I have copied the pen code which works well. Here it is...
const pen = new Pen({
damp:.2,
size:5,
}).center()

What I can't work out is how to stop the drag option.

The other thing I am trying to work out is how to clear a drawing, or delete a line.

Is that possible?

Can you help me with the code for this.?

Thanks

Rod

To stop dragging lines that have been made, set the move parameter of the Pen to false.

Usually, we use the MotionController with the Pen. Use the pressmove

new MotionController({
   target:new Pen().addTo(),
   type:"pressmove",
   damp:.5, // pen has damp too so can up this number
   speed:20
});

See the methods here https://zimjs.com/docs.html?item=Pen for doing things with the drawings like clearing etc. You can also double click or press hold lines to delete them.

Can a pen write on a page? This code doesn't work on the page but does on the stage?
const page1 = new Page(800,600, blue).addTo();
const pen = new Pen().addTo(page1).center();
const motionController = new MotionController({
target:pen,
type:"pressmove",
speed:60,
damp:.5,
mouseMoveOutside:true
});

Yes - it can - look for the container property of the Pen and or the MotionController.

Thanks, worked!

1 Like