Reputation: 48
I am trying to increase size of polygon object but instead of increasing object size it is only increasing padding between object and bounding boxes.
Here is my code:
let newObject = window.saveCoordinates;
let objectWidth = fabric.util.parseUnit(params.width + 'in');
let objectHeight = fabric.util.parseUnit(params.length + 'in');
console.log(objectWidth, objectHeight)
var polygon = new fabric.Polygon(newObject, {
left: 100,
top: 100,
width: objectWidth,
height: objectHeight,
scaleX: 1,
scaleY: 1,
originX: 0,
originY: 0,
});
polygon.setCoords();
canvas.add(polygon);
canvas.renderAll();
Upvotes: 1
Views: 637
Reputation: 2862
For polygons, paths and images you want to use the scaleX
and scaleY
properties to set the size. You can either set these values directly, or use the scaleToWidth()
or scaleToHeight()
methods to make the scale values calculate proportionately to fit your intended dimensions.
If you add a working code snippet to your question I can update this answer with an example.
Upvotes: 1