Tell me, can anyone come across such a problem.
I need to change the reference point of the coordinate system from LT to LB. On the official website there is a test for applying different origins ( http://fabricjs.com/test/misc/origin.html ).
In my project, I was not able to change originY, the same when using fiddle
https://jsfiddle.net/borneoBlack/pz4rbken/6/
var rect = new fabric.Rect({
width: 20,
height: 20,
left: 10,
top: 10,
angle: 0,
fill: '#000',
originX: 'left',
//originY: 'bottom' - does not work
originY: 'top'
});
originX
and originY
reffer to origin of the object related to TL corner of the canvas.
What you can do is to parse all the objects in canvas and adjust the position of the blocks.
Check the following example:
https://jsfiddle.net/6m034se2/
var canvas = new fabric.Canvas('canvas');
var rect = new fabric.Rect({
width: 20,
height: 20,
left: 10,
top: 10,
angle: 0,
fill: '#000',
originX: 'left',
//originY: 'bottom' - does not work
originY: 'top'
});
canvas.add(rect);
canvas.getObjects().forEach(function(block){
block.top = canvas.getHeight() - block.top - block.height;
block.setCoords();
})
canvas.renderAll();