Make a drawing (lines, circles, text) and save as an image file?

How can I use Haxe to make a drawing (I need to programmatically specify lines, maybe other shapes, and some text, providing x and y coordinates, sizes, etc.) and then save it as an image file (possibly png or ppm) on disk?

I don’t need a GUI — this is for a command line program.


Some options:

Thanks, Mark.

It’s occurred to me that I can also manually create an svg file. Looking into Getting started with Xml - Haxe - The Cross-platform Toolkit .

Hi !

Some SVG creation helpers have been discussed in this thread.

For rendering, the svg lib and maybe vectorasset might help to output a bitmap - not sure it works on the commandline.

It might be simpler to output the svg and render it as a second step with an external program/process. I use inkscape like this :

Sys.command("inkscape", [
	"--export-png", 'output/path/name.png',
	"--export-dpi", '96',
	"--export-background", "ffffff"

Would be interested in you findings ! :slight_smile:

Thanks, tokiop.

Looks like I don’t actually need a png file — I want a printed copy, and can just open the svg file in my browser and print it from there.

Will see what I can come up with!

If what you need is “lines, circles and text,” I think that SVG is always the best way to go because it will be rendered on-the-spot based on the vector-graphics drawing commands contained in the file. The files are tiny, and the output resolution is of course as high as it can be.

I use “Inkscape” to build and manage SVG files.