Live data from Hacker News

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

skia-canvas.org

21–30 of 91 posts

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

#21
post #18

Could this be consumed by Konva js for SSR ?

Yes, it may require some monkey-patching of Konva right now. But I was able to do that. Drop GitHub issue if you are interested to discuss it.

Thanks for the response. Would you suggest this lib for Konva ?

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

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

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

#24

Skia ships with a WASM build that supports node, called CanvasKit [1], whereas this module is Rust bindings? I’d be keen to know what the pros and cons of each approach are. 1. https://www.npmjs.com/package/canvaskit-wasm

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.

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

#26
post #2

Is this like a wrapper for the Rust crate? https://rust-skia.github.io/doc/skia_safe/canvas/struct.Canv...

I understand that a Skia Canvas should work with almost any programming language with just bindings [1]. I don't see anything in particular with Node.

[1] https://www.swig.org/

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

#28

Earlier quoted context omitted.

I don’t think anyone ever thought Node was a browser thing though

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.

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

#30
post #17
post #8

Earlier quoted context omitted.

They're not saying Skia itself is browserless; they're saying that "Skia Canvas" is a non-browser-based implementation of what people would normally call the browser Canvas API.

Canvas is one of the easiest browser APIs to implement because most of it maps 1:1 to PostScript-style 2D APIs. It was created by Apple as a wrapper for CoreGraphics back around Mac OS X Tiger 10.4. (IIRC, Canvas even debuted in Apple's Dashboard widgets rather than Safari? I'm not 100% sure.) I remember writing my own Canvas implementation around 2008-2009 using JavaScriptCore and CoreGraphics. It took maybe two day…

I'd love to learn more about how your 2 day implementation did fillText (incl full unicode rendering, proper text shaping etc)
Post reply on HN