Guest User

Untitled

a guest
Jan 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. function drawCircle( x, y, r, color ){
  2. var circle = new fabric.Circle({radius: r, fill: color, originX: 'center', originY: 'center', left: x, top: y, lockMovementX: true, lockMovementY: true, hasControls: false});
  3. canvas.add(circle);
  4. }
  5.  
  6. canvas.on('selection:created', function(e){
  7. var activeObjects = canvas.getActiveObjects();
  8. var length = activeObjects.length;
  9. var myForm = document.createElement("form");
  10.  
  11. for( var i=0; i<length; i++){
  12. var x = document.createElement("input");
  13. x.setAttribute('type',"text");
  14. x.setAttribute('name', "x"+i);
  15. x.setAttribute('value', activeObjects[i].left);
  16.  
  17. var y = document.createElement("input");
  18. y.setAttribute('type',"text");
  19. y.setAttribute('name', "y"+i);
  20. y.setAttribute('value', activeObjects[i].top );
  21.  
  22. var radius = document.createElement("input");
  23. radius.setAttribute('type',"text");
  24. radius.setAttribute('name', "radius"+i);
  25. radius.setAttribute('value', activeObjects[i].radius );
  26.  
  27. f.appendChild(radius);
  28. f.appendChild(x);
  29. f.appendChild(y);
  30. }
  31. })
  32.  
  33. canvas.on('selection:created', function(e){
  34. var activeObjects = canvas.getActiveObjects();
  35. var length = activeObjects.length;
  36. var myForm = document.createElement("form");
  37.  
  38. for( var i=0; i<length; i++){
  39. var obj = activeObjects[i];
  40. var objectPosition = { x: obj.left, y: obj.top };
  41. var finalPosition = fabric.util.transformPoint(objectPosition, obj.calcTransformMatrix());
  42. var x = document.createElement("input");
  43. x.setAttribute('type',"text");
  44. x.setAttribute('name', "x"+i);
  45. x.setAttribute('value', finalPosition.x);
  46.  
  47. var y = document.createElement("input");
  48. y.setAttribute('type',"text");
  49. y.setAttribute('name', "y"+i);
  50. y.setAttribute('value', finalPosition.y );
  51.  
  52. var radius = document.createElement("input");
  53. radius.setAttribute('type',"text");
  54. radius.setAttribute('name', "radius"+i);
  55. radius.setAttribute('value', activeObjects[i].radius );
  56.  
  57. f.appendChild(radius);
  58. f.appendChild(x);
  59. f.appendChild(y);
  60. }
  61. })
Add Comment
Please, Sign In to add comment