Replies: 5 comments 4 replies
-
I have been thinking of something similar for PDF. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your suggestions! I have no urgent needs for a SVG backend. It is just that I got more involved in SVG programming and became quite impressed by its abilities. The fabric.js user interface (for creating and manipulating shapes) and the object model and events adds value. I’m not so sure if the rendering to canvas adds value or is more of a burden for the fabric.js developers. This burden could be much lighter, if the rendering is delegated to SVG. |
Beta Was this translation helpful? Give feedback.
-
For those who do not know SVG well, here is an overview and some sources. First of all, there is an excellent SVG tutorial from – you guessed it – Mozilla: MDN - SVG Tutorial. SVG shapes
Text Nice feature: But W3C thinks, that SVG should be used for graphics and HTML elements like Bitmap Images Decoration
Grouping Transformations Animations Clipping / Masking Filter Interactivity The interactivity can be very helpful for user interactions if it is exposed in the fabric.js API. |
Beta Was this translation helpful? Give feedback.
-
Updated the opening post with this more complete example: On top is the usual fabric.js canvas with some objects to manipulate - including an animated SVG-Graphic and an animated GIF (the horse). Here you play it yourself and examine the (fairly simple) code: jsfiddle. |
Beta Was this translation helpful? Give feedback.
-
It will be very nice if users can opt to choose what rendering engine to use, of course like in https://zzz.dog, it renders to either canvas or SVG. But of course, this won't be an immediate need, perhaps just a wish at this moment. This is their comparison:
|
Beta Was this translation helpful? Give feedback.
-
Have you ever considered to add a SVG Backend instead of Canvas painting?
As I see it, fabric.js has three main parts:
The first two features are very precious for developers and are the foundation for many applications.
The SVG standard for vector graphics has constantly improved over the last few years and it can directly implement most of the fabric.js objects now: Shapes (rect, circle, text, path, ...), groups, transformations, animations, masks, bitmap images, filters.
Browser support is almost universal. With one exception: Filters are quite erroneous in Safari.
I think it would be possible to render the fabric.js objects to SVG graphics instead of canvas paintings. The effort looks manageable. I tried it in a tiny example.
On top is the usual fabric.js canvas with some objects to manipulate - including an animated SVG-Graphic and an animated GIF (the horse).
Below are the corresponding SVG objects with copied properties.
:
Here you play it yourself and examine the (fairly simple) code: jsfiddle.
Pro
Cons
Further Considerations
source
What do you think?
Updated March 39th, 2023: JSFiddel-Example
Beta Was this translation helpful? Give feedback.
All reactions