Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Canvas library for geometric shapes [closed]

I'm looking for a Python library for creating canvases for manipulating geometric shapes. Specifically I need the ability to create arbitrary polygons and place them on the canvas, the polygons need to have the ability to be transparent/have an alpha channel, I need to be able to edit polygons that are currently on the canvas, and I need to be able to get the actual color of a given pixel(the aggregate of all the transparent piece that are there).

Basically I'm trying to make this: http://alteredqualia.com/visualization/evolve/ in python.

like image 438
Alex Gaynor Avatar asked Dec 18 '22 09:12

Alex Gaynor


2 Answers

I think cairo will do a lot of what you want. They have python bindings, too.

The one requirement that that won't help you with is modifying previously-drawn polygons, but I don't know of any canvas that will do that for you.

like image 149
Iain Avatar answered Dec 29 '22 14:12

Iain


Sounds like a job for OpenGL.

My advice is that, whichever library you choose, you make a data structure for your polygons that suits your algorithms so that they can be more simple and readable rather then try to get these algorithms to manipulate a canvas directly. Then you can write the code that draws them separate (i.e. independent) of the main logic.

like image 29
Toni Ruža Avatar answered Dec 29 '22 16:12

Toni Ruža