Guest User

Untitled

a guest
Dec 11th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. // Create a new path once, when the script is executed:
  2. var myPath = new Path();
  3. myPath.strokeColor = 'black';
  4. myPath.selected = true;
  5.  
  6. // This function is called whenever the user
  7. // clicks the mouse in the view:
  8. var tool1 = new Tool();
  9. var tool2 = new Tool();
  10.  
  11. tool1.onMouseDown = function(event) {
  12. myPath.strokeColor = 'black';
  13. myPath.selected = true;
  14. myPath.selected = true;
  15. myPath.add(event.point);
  16. }
  17.  
  18. tool1.onMouseMove = function(event) {
  19. myPath.moveTo(event.point);
  20. myPath.lastSegment.point = event.point;
  21. }
  22.  
  23. tool1.onKeyDown = function(event) {
  24. if(event.key === 'escape') {
  25. myPath.removeSegment(myPath.segments.length - 1);
  26. myPath.selected = false;
  27. tool1.activate();
  28. myPath = new Path();
  29. }
  30. }
  31.  
  32. /*
  33. function onMouseDown(event) {
  34. // Add a segment to the path at the position of the mouse:
  35. myPath.add(event.point);
  36. }
  37.  
  38. function onMouseMove(event) {
  39. myPath.moveTo(event.point);
  40. myPath.lastSegment.point = event.point;
  41. }
  42.  
  43. function onKeyDown(event) {
  44. if(event.key === 'escape') {
  45. myPath.removeSegment(myPath.segments.length - 1);
  46. this.view.off('mousemove');
  47. }
  48. }
  49. */
Add Comment
Please, Sign In to add comment