Forum Archive

Canvas alternative for use outside Pythonista?

WyldKard

I’m using Pythonista’s built-in canvas library to draw 2D vector images for a script of mine, but would now like to run my script on a Raspberry Pi or microcontroller. Since canvas is Pythonista-only, I’m wondering if anyone knows how to either export the canvas library for use on other devices, or knows of a good alternative. I already tried Pillow, but since it’s not vector-based, the images it produces do not look as good as what canvas produces.

I mostly just need the ability to draw lines, shapes, and text, and then save the produced image as a png.

JonB

@zacbir made a canvas type module that was cross platform

https://github.com/zacbir/geometriq

Examples are here (though looks like he later renamed geometer to geometriq, you you might need to change the imports)

https://github.com/zacbir/geometer_scripts

I believe this worked with pythonista, MacOS Cairo, maybe pillow and a few others. You'll have to look at what backends you have available on your platform. I think he has some minimal support for svg, but not sure.

If you are looking for other non-python libraries, p5js is easy to learn, and is what the Khan Academy JavaScript course is based on
https://www.khanacademy.org/computing/computer-programming/programming

This is a similar canvas type idea, geared towards animation. You can use the Khan framework for creating your own projects from scratch (you don't have to just do the lessons)

cattymaloudy

thank so much https://kitchensinn.com/

jamessmith

If you want to save a large amount of your money then click the link. So, visit here to save your money.
superbsavers