Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create a new path once, when the script is executed:
- var myPath = new Path();
- myPath.strokeColor = 'black';
- myPath.selected = true;
- // This function is called whenever the user
- // clicks the mouse in the view:
- var tool1 = new Tool();
- var tool2 = new Tool();
- tool1.onMouseDown = function(event) {
- myPath.strokeColor = 'black';
- myPath.selected = true;
- myPath.selected = true;
- myPath.add(event.point);
- }
- tool1.onMouseMove = function(event) {
- myPath.moveTo(event.point);
- myPath.lastSegment.point = event.point;
- }
- tool1.onKeyDown = function(event) {
- if(event.key === 'escape') {
- myPath.removeSegment(myPath.segments.length - 1);
- myPath.selected = false;
- tool1.activate();
- myPath = new Path();
- }
- }
- /*
- function onMouseDown(event) {
- // Add a segment to the path at the position of the mouse:
- myPath.add(event.point);
- }
- function onMouseMove(event) {
- myPath.moveTo(event.point);
- myPath.lastSegment.point = event.point;
- }
- function onKeyDown(event) {
- if(event.key === 'escape') {
- myPath.removeSegment(myPath.segments.length - 1);
- this.view.off('mousemove');
- }
- }
- */
Add Comment
Please, Sign In to add comment