mardi 31 mars 2015

How to set the selections points of an object created using fabric js on canvas?

I have a canvas on which I am loading a svg image using the function fabric.loadSVGFromURL()


Then I am iterating through each object and adding that to the canvas. Here is my code :



/* Begin - Load Card from the SVG Image */
loadCardFromSVG = function loadCardFromSVG()
{
fabric.loadSVGFromURL('history/card_front.svg', function(objects, options)
{
addObjectsToCanvas(canvasFront, objects);`//call the function for adding objects to canvas`
});
}

/* End - Load Card from the SVG Image */

/* Begin - Add objects loaded from SVG to the canvas */
addObjectsToCanvas = function addObjectsToCanvas(cavasId, objects)
{
objects.forEach(function(obj)
{
obj.set(
{
borderColor: 'red',
cornerColor: 'green',
cornerSize: 6,
transparentCorners: false
});
obj.selectable = true;
cavasId.add(obj);

cavasId.setActiveObject(obj);
cavasId.renderAll();
});
}
/* End - Add objects loaded from SVG to the canvas */


All works fine using these functions. But the only problem is that the selection points of each object are being show far away from the selected object. I am not able to restore the selection points around the selected object.


Aucun commentaire:

Enregistrer un commentaire