fabricjs

Connect two objects using fabric js

牧云@^-^@ 提交于 2020-01-04 02:04:07
问题 I currently have a canvas application where I can add objects(shapes). Here is my FIDDLE. You basically click on new simulation which will initialize the canvas, then you can add a circle or rectangle. I am trying to add a feature called "Add child" where you can click on some object (shape) then click add child and add another object(shape) and they are both linked with a line. Something similar to this DEMO. I figured the pesudo code for this feature would go something like as following:

clipping image to image using canvas

我的梦境 提交于 2020-01-03 03:13:10
问题 Has anyone here have done clipping an image within an image? I've seen so far about clipping on the canvas but are all regular shapes(rectangle, circle, etc...). It would be nice if some have actually done it. P.S. with fabric.js or just the regular canvas. 回答1: Sure, you can use compositing to draw a second image only where the first image exists: ctx.drawImage(image1,0,0); // this creates the 'mask' ctx.globalCompositeOperation='source-in'; ctx.drawImage(image2,0,0); // this image only

Programmatically select object in a Fabricjs canvas from coords

ε祈祈猫儿з 提交于 2020-01-03 02:45:33
问题 I've been stuck with this for so long now. I'm using a Fabricjs canvas as a texture for a 3D model in Three.js. The model renders the canvas as a texture every time there's a change on it. I would like to click on the model and programmatically select an item on the Fabricjs canvas. I achieved to transform the 3d coords to the Fabric 2D coords with a raycaster, so I can add new items to the canvas clicking directly on the model. But I can't find the way to select a canvas object clicking on

Fabric.js layering text over Images on a Canvas

China☆狼群 提交于 2020-01-03 01:22:47
问题 So, I've just recently begun working with HTML5 and canvases , I'm currently working with fabric.js . But, I ran into an issue, and after spending the last 12 hours trying different things, I've decided to come here for help, so here it is: Using fabric.js, I've layered a bunch of images to make it how I want, but now I want to be able to write over those images using fabric.js. I can only get it to write either all of them in the write spot, but wrong z-position(the words end up all BELOW

Fabric.js animate object/image

て烟熏妆下的殇ゞ 提交于 2020-01-02 20:04:10
问题 Hello everyone this is code that ive been working with. It moves an object from A to B. What i am trying to do is have multiple points to which it would move. So from starting position A -> B, then from B -> C and so on. Maybe have some variable which would contain sets of coordinates, which would get fed into some animate function as parameters. But anything i tried resulted only in executing the last command, so it would move straight from A -> C, ignoring B. Any advice/demo appreciated.

fabric.js to show mirror image of canvas text

淺唱寂寞╮ 提交于 2020-01-02 12:01:41
问题 i am using fabric.js to write text on canva .later on click of button i want to show mirror image of text . is there any property in fabric.js which i can use to rotate text on canvas. Please check , http://jsfiddle.net/BTh6A/9/ document.getElementById( 'btn' ).addEventListener( 'click', function (e) { var obj = canvas.getActiveObject(); if ( !obj ) return; //here comes code to show mirror image obj.set( 'fill', '#FF0000' ); canvas.renderAll(); }); 回答1: Try this piece of code...I have edited

fabric.js to show mirror image of canvas text

倖福魔咒の 提交于 2020-01-02 12:01:26
问题 i am using fabric.js to write text on canva .later on click of button i want to show mirror image of text . is there any property in fabric.js which i can use to rotate text on canvas. Please check , http://jsfiddle.net/BTh6A/9/ document.getElementById( 'btn' ).addEventListener( 'click', function (e) { var obj = canvas.getActiveObject(); if ( !obj ) return; //here comes code to show mirror image obj.set( 'fill', '#FF0000' ); canvas.renderAll(); }); 回答1: Try this piece of code...I have edited

node-canvas build for AWS Lambda

▼魔方 西西 提交于 2020-01-02 08:48:51
问题 I'm a Linux & node noob. I'm trying to run FabricJS (which requires node-canvas) in AWS Lambda. I've been able to follow the instructions to get up and running on an AWS Linux EC2, however, Lambda has me at my wits end. Anyone have any tips or pointers on how to get this compiled for AW Lambda? 回答1: I found this issue in the Node Canvas GitHub site. The questioner was trying to run FabricJS in Lambda as well. Here is the relevant section with an answer: Make sure you're compiling this on the

Modify fabric.Image.fromURL after initial load using Fabric.js

会有一股神秘感。 提交于 2020-01-02 07:27:10
问题 I'm using theFabric.js library, and I've seen a lot of examples on how to load an image from a URL using Image.fromURL. Almost every example assigns the image to a variable, using this general setup: var bgnd = new fabric.Image.fromURL(bgndURL, function(oImg){ oImg.hasBorders = false; oImg.hasControls = false; // ... Modify other attributes canvas.insertAt(oImg,0); }); I've found that the attributes of the image can only be modified within the callback function when the image finishes loading

Fabric.js with Typescript and Webpack: Canvas is not a constructor

戏子无情 提交于 2020-01-02 04:13:27
问题 I'm trying to use fabric.js with Typescript and Webpack aside some other modules in a Laravel 5.4 application that work fine in the browser. @types/fabric ist installed and Typescript behaves correct. New to Typescript as well as Webpack i tried some variants with no success. The problem result.js:198 Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_1_fabric___default.a.Canvas is not a constructor Variant A code.ts import fabric from "fabric"; const canvas = new fabric.Canvas('my-canvas');