Live data from Hacker News

Skia Canvas: Browserless implementation of the HTML Canvas drawing API for node

skia-canvas.org

71–80 of 91 posts

Re: Skia Canvas: Browserless implementation of the HTML Canvas drawing API for node

#71
post #19

Out of curiosity, what's the use for such library? If you are on a desktop surely there is a better native library to draw shapes, no?

I used it (different lib, same purpose) at a previous startup, shared web whiteboard, to save the whiteboard to pdf/image.

We had a rendering engine backed by canvas, so it was easy to just redirect it to this to get the file output. (not everything was visible on the user's screen all the time so couldn't just save from the client)

Re: Skia Canvas: Browserless implementation of the HTML Canvas drawing API for node

#72
post #28

Earlier quoted context omitted.

Thinking Node is related to the browser is not uncommon. They're both javascript and javascript means "browser" to a lot of (if not most) people.

Is not only that, Node was born from the V8 implementation in Google Chrome, not the other way around.

So that means everyone pretends node is a browser thing? Why stop there? Why not call every JS library that happens to run in Node “browserless”?

Re: Skia Canvas: Browserless implementation of the HTML Canvas drawing API for node

#73
post #37
post #19

Out of curiosity, what's the use for such library? If you are on a desktop surely there is a better native library to draw shapes, no?

At Soundslice, we have a custom sheet-music-rendering graphics library in frontend JavaScript/Canvas. We also need to generate vector PDFs serverside — so we use a node library that speaks the HTML Canvas API and can generate PDFs. This way the result is exactly the same as the rendered sheet music in the web browser. Nice! The upshot is: this kind of library allows for code reuse in non-browser contexts.

On a related note, I once used puppeteer and headless chrome in a docker image to generate PDF manuals from our web page documentation using the print to PDF feature of headless chrome.

I am not sure if it would be viable to use for thousands of PDF generation per minute but it worked great. I wasted a lot of time trying to find a good lib for HTML->PDF and they all kinda sucked in different ways. The only downside is that the chrome PDF api doesn't have a way to generate a table of contents with page numbers.

Re: Skia Canvas: Browserless implementation of the HTML Canvas drawing API for node

#74
post #28

Earlier quoted context omitted.

Is not only that, Node was born from the V8 implementation in Google Chrome, not the other way around.

So that means everyone pretends node is a browser thing? Why stop there? Why not call every JS library that happens to run in Node “browserless”?

That answers the original question "Thinking Node is related to the browser is not uncommon." where Node and the browser ARE related.

Re: Skia Canvas: Browserless implementation of the HTML Canvas drawing API for node

#75
post #23
post #19

Out of curiosity, what's the use for such library? If you are on a desktop surely there is a better native library to draw shapes, no?

There isn’t really anything commonly “native” as powerful as skia for 2D drawing and a big part of skia is using the native graphics effectively, this is why it exists in the first place for browser engines. Besides having one target API is a benefit.

Direct2D, CoreGraphics,...

Re: Skia Canvas: Browserless implementation of the HTML Canvas drawing API for node

#79
If you're interested in node-compatible canvas implementations:

- canvaskit-wasm from the skia project - I don't think it's gpu-accelerated: https://github.com/google/skia/tree/main/modules/canvaskit/n...

- @napi-rs/canvas - This is the fastest binding: https://github.com/Brooooooklyn/canvas?tab=readme-ov-file#pe...

- node-canvas - Uses Cairo instead of Skia: https://github.com/Automattic/node-canvas

Re: Skia Canvas: Browserless implementation of the HTML Canvas drawing API for node

#80
post #70

https://windowjs.org is a very similar concept -- it wraps Skia and exposes it as the Canvas API, but also embeds v8 for a very small runtime instead of using Node. It was my first open-source project, released about 3 years ago. I had plans to also expose WebGL, audio, etc and make it a viable platform for Javascript-based games on desktop. Life and other projects happened instead, and development was discontinued.…

Amazing project! > but also embeds v8 for a very small runtime instead of using Node. By how much does embedding just V8 instead of using Node.js decrease the binary size? Node.js uses V8, does most of Node's binary size come from its runtime and not V8? I tried browsing the website and GitHub repo to find how many kBs or MBs typically is a Window.js binary, but didn't find an answer.

See the binary sizes in the (obsolete) releases page:

https://github.com/windowjs/windowjs/releases

About 8 MiB in the end. Note that these builds have a binary trimmed by UPX.

Post reply on HN