How to restore original size of multi-selected rescaled objects in Fabric.js?
I’m trying to implement an undo function with Fabric.js. I have this code:
How to check if a polygon has a self-intersection?
I am trying to prevent the user from drawing a polygon that has self-intersections on the canvas (using fabric.js). How can I check if a polygon has self-intersections?
How to limit the image edge not to exceed the viewport edge during panning in fabricjs
<script src=”https://unpkg.com/[email protected]/dist/fabric.min.js”></script> <style> canvas { border: 1px solid black; } </style> </head> <body> <canvas id=”c”> </canvas> <script> var c= new fabric.Canvas(‘c’,{ width: 600, height: 300 }); fabric.Image.fromURL(‘https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Apple-tree_blossoms_2017_G3.jpg/1200px-Apple-tree_blossoms_2017_G3.jpg?20180811112322’, function(img) { scale = Math.min( c.width / img.width, c.height / img.height ); img.left=(c.width – img.width * scale) / 2; img.top=(c.height – img.height * scale) / 2; img.scaleX=scale; img.scaleY=scale; […]
Why are viewportTransform[4] and viewportTransform[5] always negative when using zoomToPoint for zooming in Fabric.js?
<script src=”https://unpkg.com/[email protected]/dist/fabric.min.js”></script> <style> canvas { border: 1px rgb(0, 0, 0) ; } </style> </head> <body> <canvas id=”c”></canvas> <script> var canvas = new fabric.Canvas(‘c’,{width:200, height:200}); var rect = new fabric.Rect({ left: 100, top: 100, stroke: “red”, strokeWidth: 2, fill:”transparent”, width: 20, height: 20, originX:”center”, originY:”center” }); canvas.add(rect); canvas.on(‘mouse:wheel’, function(opt) { var delta = opt.e.deltaY; var zoom […]