COMMUNITY

Drawing rectangle, at least on Linux and Android

Is Haxe capable of using single codebase to have very basic UI (drawing rectangles) on Android and Linux?

So far I found examples of flash-based graphic code but I assume that starting new Flash-based software is a bad idea nowadays and will not run on mobile anyway.

What I found:

https://haxe.org/manual/introduction.html https://code.haxe.org/ - extreme basics, nothing about drawing on canvas or other GUI

Some flash based examples (spam filter is not allowing me to link more), is it possible to run code that is using this on Android or ios?

Welcome to Haxe :slight_smile: !

There are many ways to achieve this ( Kha, Heaps, NME, OpenFL etc… ). Most of the flash looking code you have seen can compiles to c++ code, so it’s not actually flash it is probably OpenFL and internally it uses Lime that remaps code to shaders either WebGL, OpenGL or similar.

1 Like

So code written using a Haxe toolkit will compile to multiple targets such as Linux and Android.

1 Like

So for using Haxe Kha toolkit if you want 2D then you may draw a rectangle
https://aramallo.com/articles/kha-tutorial/part-2

For OpenFL
https://books.openfl.org/openfl-developers-guide/using-the-drawing-api/drawing-shapes-using-built-in-methods.html

NME is pretty similar.

Heaps

Each toolkit has it’s own ecosystem and approach to multiplatform but they will all support linux and android. OpenFL is the most popular, NME is pretty similar written by the C++ expert, Heaps is less flash like written by the Haxe original creator, and Kha is more shader approach focused, so low level, and provides the most support for alternative shader pipelines rewritting your code for Metal, OpenGL, DirectX etc…

You can also use C# or Java and they can help you build externs to work with existing solutions but the haxe toolkits are likely better approach.

While you can compile a list of advantages it’s very much down to personal preference and if a toolkit seems to be setup well to target the platform you need, with effort any of them target pretty much anything and any of them are just as suitable.

1 Like

OpenFL is a crossplatform framework which re-implements Flash API for all major platforms: Windows, OSX, Linux, Html5, iOS and Android.
It’s quite easy to use: https://www.openfl.org/learn/haxelib/tutorials/displaying-a-bitmap/

Another crossplatform framework is Kha
I don’t have any experience with it, but there is a video tutorial series (probably a bit outdated): https://haxe.org/videos/tutorials/kha-tutorial-series/

Maybe somebody else could assemble a list of pros and cons of both frameworks.

1 Like

“OpenFL is a crossplatform framework which re-implements Flash API” - thanks, now I am far less confused!

“So for using Haxe Kha toolkit if you want 2D then you may draw a rectangle” - I was looking for something like that, I will try it first as it is the first one with 2D graphics example.

OpenFL - Wikipedia article about Haxe has “C++ applications built with OpenFL suffer major performance issues”, with reference from 2014. Is it still a problem?

heaps seems dead/not maintained judging by expired gifs on their main site (for more than 25 days - see https://github.com/HeapsIO/heaps.io/issues/60 )

“So code written using a Haxe toolkit will compile to multiple targets such as Linux and Android.” - how Haxe toolkit is related to “Get started with $LANGUAGE” at https://haxe.org/documentation/introduction/ ?

I though that Haxe is a programming language - and instead I see list of other languages.

So my plan is to try (1) Kha (2) OpenFL (3) NME and if all that fails - look again for Kotlin native documentation.

That should be read like “Get started with compiling Haxe to $LANGUAGE”.
Haxe is a language designed to be compiled to various other languages and virtual machines.
You write in Haxe and compile it into JavaScript (for example). And then use JavaScript ecosystem to run your app.

1 Like

I would not hold much store on what Wikipedia says, I remember many corrections being lodged and many of them ignored. OpenFL works well and gets better every day, and is easy to use, occasionally tricky to setup depending on the target.

Heaps is not dead it’s used by serious developers to create award winning games, however if your not used to reading large library source code - it maybe a bit daunting, most haxe projects are only used by small number and so documentation is often limited and may only cover setup. There is a discord channel for Heaps.