Simple graphical API with transparency, polygons, image pixel readout?

I need a simple graphics library that supports the following functions:

  • The ability to draw polygons (not just rectangles!) With RGBA colors (i.e. partially transparent),
  • Ability to download bitmap images,
  • The ability to read the current pixel color in a given coordinate.

Ideal to use JavaScript or Python.

It seems that HTML 5 Canvas can handle # 2 and # 3, but not # 1, while SVG can process # 1 and # 2, but not # 3. Am I missing something (about one of these two)? Or are there other alternatives?

+2
source share
5 answers

PyGame can do all this. OTOH, I don’t think that it integrates too well into the graphical interface.

+3
source

I ended up going with Canvas. The "secret" of polygons uses paths. Thank "tur1ng"

+2
source

GameJs does this and much more - it looks like PyGame mentioned.

http://gamejs.org

The ability to draw polygons (not just rectangles!) With RGBA colors (i.e. partially transparent),

gamejs.draw.polygon (surface, color, pointlist, width) 

Transparent colors can be defined as "rgba (50, 50, 50, 0,1)" (the latter is alpha)

http://docs.gamejs.org/gamejs/draw/#polygon

Ability to download bitmap images,

 var surface = gamejs.image.load('images/foo.png') 

http://docs.gamejs.org/gamejs/image/

Ability to read the current pixel color in a given coordinate.

 // a surface array is a special DOM canvas array // that is superfast for per pixel access / manipulation var srfArray = new SurfaceArray(display); srfArray.set(50, 100, [255, 0, 0, 100]); srfArray.get(20, 30); 

http://docs.gamejs.org/gamejs/surfacearray/

+1
source

I voted for PyGame, but I would also like to point out that the new QT graphics library seems quite capable. I haven't used PyQT with QT4 yet, but I really like developing PyQT with QT3.

0
source
-1
source

All Articles