For folks who have used this, why would you choose this instead of SVG inside React, Svelte, etc?
That's my question, because SVG is declarative vector graphics. It has a ton of features, can be SSR'ed, written and used in various apps... I wish the performance issue were either fixed or dispelled. I think I recall some SVG performance work being done couple of years back.
Konva.js - Declarative 2D Canvas for React, Vue, and Svelte
41–50 of 76 posts
Re: Konva.js - Declarative 2D Canvas for React, Vue, and Svelte
#42For folks who have used this, why would you choose this instead of SVG inside React, Svelte, etc?
It is much much MUCH faster. SVGs really slow down on some browsers (especially Firefox) after a certain level of complexity and interactivity.
Re: Konva.js - Declarative 2D Canvas for React, Vue, and Svelte
#43Re: Konva.js - Declarative 2D Canvas for React, Vue, and Svelte
#44Re: Konva.js - Declarative 2D Canvas for React, Vue, and Svelte
#45Earlier quoted context omitted.
SVG export feels like it would be borderline impossible. Raster graphics to vector?
The underlying shapes are defined by geometries (so vectors) and then rasterized to canvas. So the SVG export could happen before the rasterization. There are other libs that are native SVG though, so why even use Konva? The benefit of Canvas is that it can be a lot, LOT faster than having multiple complex SVGs. SVG is especially slow on Firefox IIRC.
Konva to set the scene, SVG for final touches before you publish the image somewhere
Re: Konva.js - Declarative 2D Canvas for React, Vue, and Svelte
#46Don't know about the library but the spreadsheet project built on top is impressive https://www.rowsncolumns.app/
Re: Konva.js - Declarative 2D Canvas for React, Vue, and Svelte
#47I evaluated this vs pixi and native canvas API. In the end I decided to use native API. Konva didn't have enough performance for my use case and pixi webgl has a limit on the number of canvases on the screen at the same time The native API is easy to use and well documented. It also performs well enough to animate charts at 60fps on modern hw for my use case. I also like that there are no libraries to update
What was your use case? Konva is a pretty high level abstraction, more like a lightweight interactive geometry & paint engine than a graphics API. It must've taken quite a bit of work to recreate similar functionality using native APIs?
Interaction is also supported by the API with hit regions, though I've opted to do my calculations. But I agree that interaction is where Konva would probably have shined.
Re: Konva.js - Declarative 2D Canvas for React, Vue, and Svelte
#48Don't know about the library but the spreadsheet project built on top is impressive https://www.rowsncolumns.app/
That component is not built on Konva though. Canvas has long been known to be the perf endgame for web, see google sheets etc .
Re: Konva.js - Declarative 2D Canvas for React, Vue, and Svelte
#49For folks who have used this, why would you choose this instead of SVG inside React, Svelte, etc?
Konva.js solved the issue for me. It was very easy for me to convert this entire interactive piece into Konva.js, and performance is amazing. No memory issues now at all, and I can throw thousands more interactive items than I could before. It was very easy to reuse the interactivity code with Konva, and now my web application has great performance again.
Re: Konva.js - Declarative 2D Canvas for React, Vue, and Svelte
#50I joined a project last year which uses Konva inside an Angular application. It was my first time doing any kind of canvas programming, but the ergonomics of konva can be picked up quite rapidly and I've been enjoying quite a lot. We're working on performance-sensitive project, so one lesson we learned is that all shapes listen to all mouse events by default. We didn't even have lots of shapes, but this was enough to…
Konva looks awesome, but canvas based. For more performance I switched from canvas to pixi, which is webgl/webgpu based.
Drawing can be also expensive there(in some cases even more so), but if you can manage to put it in a texture in time, you can have looooots of moving animated shapes even on mediocre mobile phones.