8 ms·
Pixie – A full-featured 2D graphics library for Nim
- tomcam 5y agoStunning. Already supports all popular font types, image types, and SVG.
- elcritch 5y agoNot to mention operations like "complex blends: Darken, Multiply, Color Dodge, Hue, Luminosity... etc" and many SIMD accelerations. It also has Node, Python, and C interfaces. Though I haven't found an excuse to use it yet. Surely there's got to be some excuse... ;)
- RazrFalcon 5y agoIf you're looking for a small, fast CPU-based 2D library, you might be interested in https://github.com/RazrFalcon/tiny-skia https://github.com/RazrFalcon/tiny-skia Just like Skia, all pixel accesses is SIMD accelerated. It doesn't have C bindings, but they can be trivially implemented.
- elcritch 5y agoAh, that's the thing.. I don't have a reason/need for using a fast 2d library. It's that Pixie's Nim API makes me want to have a reason. Like maybe it'd be fun to write a modern plotting backend with it! Currently even one of Julia-lang's best plot backends uses a C-based plotting library, GR [1]. It's a pain to use from raw C bindings though. :/ Also while Rust is great, I'm too lazy to program in it. All them `& mut<RC<box<mything>>` things. ;) (Yes I know that's not real Rust code...) Though tiny-skia does look like a well done library! 1: https://gr.readthedocs.io/ https://gr.readthedocs.io/
- jahewson 5y agoIt’s really great work. The font support is a bit behind the times though, and text shaping is non-existent. I see so many libraries fall at that hurdle, they think they can do it themselves then when they realise it’s hard and requires a team of people they either abandon it or tell you to use harfbuzz without the necessary integration points. Hopefully that won’t be the case here!
- sanxiyn 5y agoRust managed to get text shaping (https://github.com/RazrFalcon/rustybuzz https://github.com/RazrFalcon/rustybuzz), you can certainly do it yourself but it's just a lot of work...
- deleted 5y ago[deleted]
- treeform 5y agoI agree shaping is hard. But so is a lot of other things we have done. We will just take it one setup at a time. I am sure with time we will conquer shaping as well.
- RattleyCooper 5y agoI don't think treeform and guzba will have much trouble, honestly.
- RodgerTheGreat 5y agoDug into the source for the GIF decoder a bit and it looks like it only supports the most basic features- no windowing, animation, local colortables, or background colors. I suspect many optimized static GIFs won't decode correctly. Still, everything has to start somewhere!
- treeform 5y agoWe did not really "need" a GIF decoder but it was a fun thing to make. It can decode many many gifs, but yes its still missing features. I hope to get to them though eventually.
- Guzba 5y agoSVG support has been really helpful for me to see a diverse and "real world" set of rendering results when working on Pixie. And for testing it's great to be able to grab huge sets of open source SVG files and check our results. For example, I have a few "megatests" where I render entire icon sets or emoji sets such as https://raw.githubusercontent.com/treeform/pixie/master/tests/images/svg/twemoji.png https://raw.githubusercontent.com/treeform/pixie/master/test... and https://raw.githubusercontent.com/treeform/pixie/master/tests/images/svg/flat-color-icons.png https://raw.githubusercontent.com/treeform/pixie/master/test... Running these tests helps me feel more confident that changes I'm making are not breaking things.
- RazrFalcon 5y agoI'm sure you will be interested in https://github.com/RazrFalcon/resvg-test-suite https://github.com/RazrFalcon/resvg-test-suite From a quick glance, pixie should pass 10-20% of those tests. Yes, SVG is that complex.
- losethos7 5y agoSimilar to skia or cairo? Except it doesn't actually target hardware acceleration? -- if it does, the documentation is pretty bad about expressing that. That's a pretty big difference.
- vladharbuz 5y agoIs anyone aware of anything like this for Go, Rust, Zig or similar?
- deleted 5y ago[deleted]
- muizelaar 5y agoRust: https://github.com/RazrFalcon/tiny-skia https://github.com/RazrFalcon/tiny-skia https://github.com/jrmuizel/raqote https://github.com/jrmuizel/raqote Go: https://github.com/tdewolff/canvas https://github.com/tdewolff/canvas
- adamnemecek 5y agoYou should also check out the femtovg project, a 2D rendering API that sixtyfps relies on. https://github.com/femtovg/femtovg https://github.com/femtovg/femtovg It's a decent starting point for trying to build your own toolkit. I have recently added a wgpu backend but for now it lives in my fork https://github.com/adamnemecek/femtovg https://github.com/adamnemecek/femtovg run the demo with `cargo run --example wgpu_demo --release`. Also join the femtovg discord https://discord.gg/V69VdVu https://discord.gg/V69VdVu
- vladharbuz 5y agoVery cool, thank you! :)
- brundolf 5y agohttps://lib.rs/crates/nannou https://lib.rs/crates/nannou
- vladharbuz 5y agoThat's super cool, thank you! :)
- diskzero 5y agoThis was the final presentation at NimConf in June and I was blown away, as I am sure many others were. The fact that this library exists makes the task of creating a high quality retained-mode UI library in Nim much easier. You don't have to try and wrangle Pango/Cairo/Skia to act as your foundation.
- treeform 5y agoThank you for watching our pixie presentation!
- diskzero 5y agoSure. I think they saved the best for the last, but I am biased as someone who has developed a lot of UI frameworks. The other presentations were great as well.
- irq-1 5y ago(Off topic.) What are your thoughts on a UI framework having a tightly bound language, like tcl/tk, js/html, etc...?
- habibur 5y agoI had been using ImageMagick for these types of things. Wondering how pixie improves over it. Without knowing how much overhead Nim brings in, I still believe it would have been better if this library preliminary was a C or C++ lib and then had binding for all the other languages.
- diskzero 5y agoI am not sure Pixie improves over ImageMagick. Perhaps it has some more advanced blend modes or other algorithms that ImageMagick hasn't implemented. ImageMagick is really great for pipelines of conversions. I see Pixie being more of a Quartz, Cairo, Skia, etc. for the Nim platform that can serve as the low-level canvas for a lot of higher-level functionality. Sadly, I am not enough of a Nim expert to know the trade-offs between using native code or importing C libraries.
- gavinray 5y ago> Sadly, I am not enough of a Nim expert to know the trade-offs between using native code or importing C libraries. I'm no expert either but (not sure if this is what you're getting at) Nim is "compiled" to C/C++/JS and you have nearly full control over emitted code. So I don't think it's far-fetched to emit C with hand optimizations if you really need them. That's the weird thing about Nim. It's not really a new language so much as a syntax and front end to several existing languages. If you compile in "-d:danger" mode turning off all checks and highest optimizations, the C code it spits out is pretty human readable even.
- PMunch 5y ago> That's the weird thing about Nim. It's not really a new language so much as a syntax and front end to several existing languages. This is a bit of an over-simplification. Nim does a lot of stuff on its own, so you won't be able to convert back from C to Nim for example. The most obvious being of course the macro system that is just normal Nim code but is evaluated at compile-time and generates code for you. In fact you can use the compiler to evaluate Nim without compiling it, so it certainly falls into the language in its own right category.
- MattRix 5y agoLooks like a great library, though the name is going to cause some people to think it’s related to pixi.js
- tomrod 5y agoIs pixi.js pretty big? I haven't heard of it before tonight, and I thought I'd had exposure to most of the bigger JS frameworks via HN (I'm not a JS guy, more Python).
- MattRix 5y agoYup, Pixi is the most popular javascript 2D game engine/renderer, with over 34k stars on github. It’s used all over the place.
- beebeepka 5y agoAs good as pixijs is, I wouldn't call it a gaming engine. Unless things have evolved in that direction. I haven't used it in 3 years or so
- MattRix 5y agoWell it’s more than just a renderer, since it also handles interaction… so I wouldn’t say it’s wrong to call it an engine, but you can just call it a framework if you want.
- treeform 5y agoThat's unfortunate. I did not know about pixi.js when we picked the name. It feels like all of the cool names are taken! When we were thinking of a name we just looked around the Nim community for name collisions.
- bytehowl 5y agoSo, I've been thinking about making a library like yours, and as with most things I think about nothing came of it. However, I did have a name picked out: "Graffiti". I think it's kinda cool and relevant, and a quick search didn't reveal any other library with the same name. If you're up for rebranding, feel free to use it :)
- tomrod 5y agoNim is such a breath of fresh air when I read it. This library looks great. I've been trying to learn it / grok its documentation for awhile. Any suggestions on how to learn it better? I've given Exercism.IO a try (disclaimer: satisfied learner from there but not trying to shill) but I've had difficulty adopting the language from a Python background.
- foerbert 5y agoDespite completely disagreeing with you on the first point, I've had some of the same experience too. Some years ago when I was going through languages frequently, I was pretty interested in it for a bit, but found it kind of hard to get into and my interest ultimately wandered. I thought a large part of that was due to my unusually strong dislike of the syntax, and that that was why I found it unusually difficult to grok. Maybe it wasn't. Interesting.
- elcritch 5y agoNim's a pleasant language to read/write! Out of curiosity, what aspects have you found challenging to learn? One caveat of imitating Python's syntax is that the semantics are not the same as in Python and are closer to Pascal/Ada in many ways. If you haven't read through the Nim-for-Pythoners [1] it'd be good. I read the "nim manual" [2] constantly and just use ctrl-f. Though Nim Basics by narimiran is a nice tutorial form [3]. There's a few standard links: 1: https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programm... 2: https://nim-lang.org/docs/manual.html https://nim-lang.org/docs/manual.html 3: https://narimiran.github.io/nim-basics/ https://narimiran.github.io/nim-basics/
- deleted 5y ago[deleted]
- jillesvangurp 5y agoI just read through a bit of their documentation. So, I only have all of five minutes of experience with Nim. But it looks like a pleasant language to work with. I could see this becoming popular and it looks like something I could figure out pretty easily. I did not see any allocs/de-allocs, which suggests some kind of garbage collector is being used? I guess a lot of that is straightforward with stack allocated data structures going out of scope. But that would put this language in the same realm as Go and not Rust/C/C++, which don't rely on garbage collectors. I'm mainly doing Kotlin currently, which also has a multi platform compiler (with native, js, and jvm compilers). Though particularly the native compiler is a bit a work in progress. But, Nim could be considered similar to that as well. Though obviously the languages are very different, what is similar though is a focus on programmer convenience. It's something I really appreciate in Kotlin and it seems this language has a lot of that too. It will be interesting to see how this language grows and evolves. Looking at Rust and Go in recent years, there are a bunch of gnarly topics that inevitably come up like how to deal with asynchronous stuff and co-routines, generics, error handling, etc. Kotlin also had its fair share of that. That's when languages get more complicated. I think Rust is a good example of a language that has a pretty high level of complexity at this point. Just a first impression. But mostly a good one.
- analognoise 5y agoReminds me of BGRABitmap from Lazarus/FreePascal. https://github.com/bgrabitmap/bgracontrols https://github.com/bgrabitmap/bgracontrols (BGRAControls contains the BGRABitmap components). It's sad Lazarus/FreePascal doesn't get much play, because high quality libraries like this have existed for years for it and it seems to not get much traction.
- diskzero 5y agoWhy do you think that is? Pascal as a language? The IDE? Is there a lack of success stories or high profile applications?
- eyelidlessness 5y agoI for one welcome the butt caps.
- eyelidlessness 5y agoI guess some people don’t welcome butt caps. The world is a complex place.
- eyelidlessness 5y agoStill stanning for butt caps
- Guzba 5y agoFor those using Python, we just got our Python bindings for Pixie up onto pip. Repo here https://github.com/treeform/pixie-python https://github.com/treeform/pixie-python It's extremely fresh but our tests are working so consider giving it a try. For those interested in Nim's meta-programming, we're generating those Python bindings for Pixie from our Nim code using https://github.com/treeform/genny https://github.com/treeform/genny here https://github.com/treeform/pixie/blob/master/bindings/bindings.nim https://github.com/treeform/pixie/blob/master/bindings/bindi... More languages in the works.
- pjs_ 5y agoUnreal - I pip-installed the library, ran the demos, and it just worked! After years of mucking about with pyCairo this is a very pleasant surprise!
- gnramires 5y agoI'll probably take this up for my artistic work (currently using PyGame and p5.js). Thanks!
- chmod775 5y agoThis has a high risk of being confused with PixiJS, which is often just referred to as pixi, and is a popular 2D WebGL renderer. https://github.com/pixijs/pixijs https://github.com/pixijs/pixijs This project is likely to get drowned out by pixi search results when its users try to Google anything related to it.
- hutzlibu 5y agoYes, I also just came here to ask a question about pixijs ...
- hnlmorg 5y agoIt's almost impossible to come up with names these days due to the massive amount of software released every year. It's so bad that I automatically include the language name as well as the framework name in any search I do. In this instance the Nim and JS libraries have different names (and even different spellings of the common subset) so I don't see an issue.
- vanderZwan 5y ago> In this instance the Nim and JS libraries have different names They're both named "Pixie" and they're both graphics libraries. I assume you meant something else than what you literally said, but I'm not sure what
- ShangSixtyTwo 5y ago"Pixi" != "Pixie"
- hithereagain 5y agoBut "Pixi" == "Pixie" when evaluated by humans
- hnlmorg 5y ago
- jb1991 5y agoAfter the conference talk, I rushed to try it out. I remember having quite some difficulty getting the demos to work well on a Mac and eventually gave up.
- treeform 5y agoCan you give us more details on what did not work for you? We would love to fix it.
- riofoxx 5y agoT.o a.s.s.i.s.t y.o.u i.n t.r.a.d.e.s f.o.r b.e.t.t.e.r i.m.p.r.o.v.e.m.e.n.t on c.r.y.p.t.o.c.u.r.r.e.n.c.y W.h.a.t.s.A.p.p (+13052395906)
- tenaciousDaniel 5y agoI've been looking for an alternative to Skia so this looks interesting. Why Nim though? I've never heard of it before.
- treeform 5y agoI chose to write Pixie in Nim because I really like Nim: * Nim very fast. I can beat any C/C++ program in performance using same tricks as they do. Cleaver Memory management, inlining, static analysis, SIMD. There is no wall that you run where you need to drop into "C". * Nim is very easy to write, I came from Python/CoffeeScript and it was a very easy transition. Nim feels like Python with Types. * Nim is very powerful with generics/templates/macros allowing you to write DSLs quickly. * Nim has very easy interop with C. So its very easy to use existing C libraries or low level operating system APIs. * Nim works everywhere: From Desktop Windows/Mac/Linux, to mobile iOS/Android to embeaded devices. It even compiles to JavaScript (like CoffeeScript/Typescript or WASM) or GL shader language. It run anywhere. * Nim has a smaller community that has not been overrun by complexity or apathy. Everything feels green and fresh and everyone helps everyone else. But still big enough that there are libraries for most things.