Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function drawCircle( x, y, r, color ){
- var circle = new fabric.Circle({radius: r, fill: color, originX: 'center', originY: 'center', left: x, top: y, lockMovementX: true, lockMovementY: true, hasControls: false});
- canvas.add(circle);
- }
- canvas.on('selection:created', function(e){
- var activeObjects = canvas.getActiveObjects();
- var length = activeObjects.length;
- var myForm = document.createElement("form");
- for( var i=0; i<length; i++){
- var x = document.createElement("input");
- x.setAttribute('type',"text");
- x.setAttribute('name', "x"+i);
- x.setAttribute('value', activeObjects[i].left);
- var y = document.createElement("input");
- y.setAttribute('type',"text");
- y.setAttribute('name', "y"+i);
- y.setAttribute('value', activeObjects[i].top );
- var radius = document.createElement("input");
- radius.setAttribute('type',"text");
- radius.setAttribute('name', "radius"+i);
- radius.setAttribute('value', activeObjects[i].radius );
- f.appendChild(radius);
- f.appendChild(x);
- f.appendChild(y);
- }
- })
- canvas.on('selection:created', function(e){
- var activeObjects = canvas.getActiveObjects();
- var length = activeObjects.length;
- var myForm = document.createElement("form");
- for( var i=0; i<length; i++){
- var obj = activeObjects[i];
- var objectPosition = { x: obj.left, y: obj.top };
- var finalPosition = fabric.util.transformPoint(objectPosition, obj.calcTransformMatrix());
- var x = document.createElement("input");
- x.setAttribute('type',"text");
- x.setAttribute('name', "x"+i);
- x.setAttribute('value', finalPosition.x);
- var y = document.createElement("input");
- y.setAttribute('type',"text");
- y.setAttribute('name', "y"+i);
- y.setAttribute('value', finalPosition.y );
- var radius = document.createElement("input");
- radius.setAttribute('type',"text");
- radius.setAttribute('name', "radius"+i);
- radius.setAttribute('value', activeObjects[i].radius );
- f.appendChild(radius);
- f.appendChild(x);
- f.appendChild(y);
- }
- })
Add Comment
Please, Sign In to add comment