Live data from Hacker News

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

skia-canvas.org

61–70 of 91 posts

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

#62

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.…

That’s pretty cool! But v8 alone kind of sucks unless you specifically want isolation. Sometimes you just want to make a network request, you know?

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

#63
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.

Curious: What other libs are you using for the PDF generation?

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

#64

Are there plans for a C API? The missing C API for Skia is most likely why Cairo is still alive.

I did a little work on a C API for Skia a long time ago. We didn't have a good use case at the time, so the project was dropped.

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

#65

Earlier quoted context omitted.

Note that it's not so much "rust bindings" as a pre-compiled node binary (that happens to be generated off of a mixed Rust/C++ codebase). So that's really the main difference: WASM needs a separate runtime, whereas a node binary doesn't.

> WASM needs a separate runtime, whereas a node binary doesn't. FWIW, node ships with a WASM runtime. See https://nodejs.org/en/learn/getting-started/nodejs-with-weba...

The more accurate way to say that is: V8 is also a WASM runtime.

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

#66

Are there plans for a C API? The missing C API for Skia is most likely why Cairo is still alive.

Impeller - Flutter’s rendering library that replaces Skia on iOS and Android - is working on a C API: https://github.com/flutter/engine/blob/main/impeller/toolkit...

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

#67

Earlier quoted context omitted.

The only similarity between the two is that they deal with images. That library only resizes and does other basic pixel level operations. Skia is for drawing vector graphics.

> Skia is for drawing vector graphics. What do you mean by "vector graphics"? Both Canvas and ImageData work only with pixels.

Skia’s api is focused around using postscript-like commands such as “move to” “line to”, etc to produce vectors that it rasterizes.

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

#68
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?

It's portable? What other GPU accelerated 2D rendering library is?

One the one hand this is lower-level. On the other hand, I've used puppeteer as my 2D graphics library. I get Canvas 2D, and WebGL, and WebGPU, and all of HTML/CSS (so Text with effects, background images, CSS transforms, etc). I get image and video loading. I can then use the screenshot functionality to make an image of whatever I put together. It's overkill, but for my use case I don't care. It works, it's cross platform, it solves my problem.

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

#69

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.…

That’s pretty cool! But v8 alone kind of sucks unless you specifically want isolation. Sometimes you just want to make a network request, you know?

> Sometimes you just want to make a network request

In a drawing tool / library?

That's just asking for trouble. By spec, SVG allows for XXE shenanigans. I'd rather not worry that any image file I process might exfiltrate my data.

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

#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.

Post reply on HN