Comments (6)
hey @emorling, do you mean the fabric canvas instance ? from this const { selectedObjects, editor, onReady } = useFabricJSEditor()
then editor.canvas.add( ... )
from fabricjs-react.
I am not sure I understand how to do this.
I understand that we can add an Image object using: editor.canvas.add( ... )
But how do we for example do this prior to adding it:
fabric.Image.fromURL('my_image.png',(oImg) => { });
from fabricjs-react.
Ah alright you are almost there, from your project you have to regular install the fabric dependency because fabricjs-react
needs it as peer dependency, then you can do exactly that:
import { fabric } from 'fabric'; // this also installed on your project
import { useFabricJSEditor } from 'fabricjs-react';
const { selectedObjects, editor, onReady } = useFabricJSEditor();
fabric.Image.fromURL('my_image.png', function(oImg) {
editor.canvas.add( ... )
})
You can use this boilerplate we created https://codesandbox.io/s/flamboyant-wind-ff3x8
from fabricjs-react.
Fabulous! You are one of the smartest people on the planet!
BTW do you have any consulting hours this weekend, to solve this: fabricjs/fabric.js#6883
from fabricjs-react.
from fabricjs-react.
Hi. I tested the above code to render an image on the canvas, but there are multiple images being rendered. Like a million. What am I doing wrong? Here's the sandbox: https://y0rq7.csb.app/ and here's the code:
import React from "react";
import { fabric } from "fabric";
import { FabricJSCanvas, useFabricJSEditor } from "fabricjs-react";
const App = () => {
const { selectedObjects, editor, onReady } = useFabricJSEditor();
fabric.Image.fromURL("https://i.imgur.com/8zvUjul.jpg", function (oImg) {
editor?.canvas.add(oImg);
});
return (
<div>
<FabricJSCanvas className="sample-canvas" onReady={onReady} />
</div>
);
};
export default App;
from fabricjs-react.
Related Issues (20)
- Fabric v5 ? HOT 7
- canvas.on events fires two times HOT 3
- how can i change font size by progressbar please help me also want to make font bold italic underline HOT 2
- can you please help how to export canvas as pdf HOT 1
- How can I create multiple canvas and also store the current state of those canvases ? HOT 2
- How can I create multiple canvases and use them on single page. HOT 6
- How do I download the images I add to the canvas HOT 3
- change canvas using FabricJSCanvas? HOT 2
- Is it possible to change border-radius? HOT 3
- Upgrade to react18 HOT 2
- support custom build of fabricjs
- Text disappears on edit / selected HOT 2
- Adding new features to the package HOT 4
- Cannot read properties of null (reading 'useState') HOT 1
- Fabricjs6 beta12 giving error for textbox HOT 3
- Fix "exports" field in package.json for TypeScript typings resolution HOT 1
- Is there any documentation? HOT 3
- useFabricJSEditor hook returns undefined for editor HOT 2
- `selectedObjects` reports incorrect amount when shift clicking. HOT 1
- React FabricJS Documentation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fabricjs-react.