fabricjs

Fabricjs: Show horizontal and vertical position line on drag

痴心易碎 提交于 2019-12-23 02:58:29
问题 I am using fabricjs 1.5 and I am stuck on on thing. I want to show the dotted lines horizontally and vertically whenever I start to drag my object. Purpose of these lines is to give some idea to the user that where is the object with respect to the canvas and other objects. I have searched on many websites and could not find any solution or even any reference related to this problem and hence I could not start anything. It would be great help if someone can put me in right direction. Thanks.

Scale canvas background image dynamically using fabric.js

╄→尐↘猪︶ㄣ 提交于 2019-12-23 02:52:48
问题 Here i am trying to scale canvas background image dynamically.On click .set_bg_images i am setting up the canvas background image dynamically its working good and i have added button change_scale on click this button i am trying to change the scale of canvas background image,after setting up the background image and when click the change scale button the entire canvas background image going to diapered.Give me some idea to do this. **//Here i am setting canvas background image** $(".set_bg

Draw Image on Canvas and export print quality image

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 01:38:14
问题 What I am Doing: I am using Fabric.js to develop a canvas application. Users can place image or texts in the canvas What I want to Do: When the user downloads the image,the user should be able to print it. Currently I am working on length: 5 X 8 (inches) . In Fabric.js , toDataURL() function by default will give 72 DPI image and I am planning on using PHP to convert it into 300dpi image. So to create a high quality image of 5X8 with 300dpi , the image should be 1500px X 2400px . But I cant

How to set relative position (oCoords) in FabricJs?

假装没事ソ 提交于 2019-12-23 00:50:25
问题 I have a Text in fabricJs. I set top and left. This sets the aCoords properly to those values. However the oCoords dont match. And the Text is not displayed at the right position. I suspect that I need to set to oCoords somehow. So that the Text is displayed at the right pixel coordinates (top & left) on the canvas. 回答1: aCoords and oCoords are two different things and should not be in sync. In your comment you speak about scaled canvas. Top and Left are 2 absolute values that represent the

Images filled in the shapes are not loading with loadFromJSON in FabricJS

我们两清 提交于 2019-12-22 18:09:04
问题 I have JSON data with fabric Rect object. When I try to load this JSON data on to fabric canvas with LoadFromJSON , Shapes are loading perfectly but patterns filled in the shapes are not rendering. The patterns are rendered only after clicking on shape. I have copied my code in fabric Kitchen sink execute module and i tried to execute it. But it is also not working as expected. My Code: var jsonD = '{"objects":[{"type":"rect","originX":"center","originY":"center","left":222.92,"top":237,

fabric js or imagick remove white from image

旧巷老猫 提交于 2019-12-22 14:48:09
问题 I got this situation which is hard for me to search on Google and explain. Our company prints photos on aluminium and we give our customers two choices. The first choice is to print their pictures on aluminium just like they gave the picture to us, so if the picture has a white background the picture gets printed with a white background. Easy like that. The second option is that we can print their picture without using white. instead of all the "white values" (<- the best I can come up with

Disabling the snapping-grid in fabricjs

喜你入骨 提交于 2019-12-22 11:45:36
问题 I managed to snap the objects to grid using round-off. canvas.on('object:moving', function(options) { options.target.set({ left: Math.round(options.target.left / grid) * grid, top: Math.round(options.target.top / grid) * grid }); }); How do I disable this, say, on button click? I tried using a flag isGridEnabled and doing: canvas.on('object:moving', function(options) { options.target.set({ left: options.target.left, top: options.target.top }); }); but the object(s) still snap to grid! 回答1:

Fabric.js colors are changing to black in subclassed fabric.Group

不问归期 提交于 2019-12-22 11:23:05
问题 I am trying to subclass fabric.Group and load a JSON string into it. The problem I'm having is that the color of the fabric.Rect in the subclassed group is getting changed to black. When I do it directly in fabric.Group it works great. I've been playing with variations on fromObject but I can't seem to figure out what I'm doing wrong. The change seems to happen when I "enliven" the objects in the group. Here is a fiddle demonstrating my problem https://jsfiddle.net/adgu/49feomm7/ Click on the

How to select child elements after using groupSVGElements

喜欢而已 提交于 2019-12-22 10:58:23
问题 I am loading an svg into Fabric which has child elements. I'm grouping them using groupSVGElements(). I need to be able select each child element - that is an onclick event that allows me to select a child object. I've thrown together this fiddle http://jsfiddle.net/AnQW5/2/ Although I can list out the child objects of the group via getObjects, theres no way that I can see to determine which object was clicked. So : canvas.observe('object:selected', function(e) { console.log(e.target

object alignment in fabric js

这一生的挚爱 提交于 2019-12-22 09:35:59
问题 I am trying to implement object alignment (i.e Right, Center, Left, Top, Bottom) in canvas. Lets say user selected one object (i.e Text or Image) then if user hit the Align right option then that selected object should align to right side. I have tried below 2 methods but no success. var canvas = new fabric.Canvas('a'); canvas.add(new fabric.Rect({ left: 50, top: 50, height: 50, width: 50, fill: 'red' })); canvas.add(new fabric.Rect({ left: 130, top: 50, height: 50, width: 50, fill: 'green' }