Is there a multiplatform (I specifically need JVM ...
# multiplatform
l
Is there a multiplatform (I specifically need JVM and Linux native, and possibly JS) library that can open a graphical window, and draw basic graphics (text, lines, circles, etc). I have written dedicated code calling into Javafx, SDL and the JS API's to do the basic stuff, but every single feature I add needs to be reimplemented multiple times, and it's a hassle.
h
Did you try compose? It has a canvas were you can draw freely
1
l
I did not try compose. I'm looking at skiko right now, which is very close to what I need, but it seems to be event-driven, which doesn't work very well for me.
I don't know how easy it is to use compose to just open a window and draw in it though. The API seems a lot more complicated than what I'm looking for.
h
Compose Multiplatform works differently than traditional UIs, and it has its own learning curve. There are good tutorials on Google's Android developers pathways about how it works (the compose sections apply to any platform with compose) But for your use case, probably a quick search on google may give good results.
l
Yeah, in my particular case, I'm working on a programming language interpreter. And I want to expose some simple drawing functions in the language.
I am already able to draw graphics by creating a bitmap, but 2D graphics operations are not available, and I don't want to reimplement something like skia.
d
Yeah, use the Compose Canvas. You'll get all the 2D graphics primitive you need in there.
e
if you're just drawing to a bitmap-backed canvas, SkCanvas operations don't require an event loop
l
@ephemient oh, thanks a lot.
That's nice. Are you saying I can use the existing bitmap stuff I have that already integrates with the different backends, and then just use the skiko library to draw to them?
e
you'll have to wire it all up but you should be able to