4 ms·
For Python you could use the pyglet OpenGL library to do both 2D and 3D https://github.com/pyglet/pyglet https://github.com/pyglet/pyglet For Scratch, the pen
by tmaly 5y ago
For Python you could use the pyglet OpenGL library to do both 2D and 3D https://github.com/pyglet/pyglet https://github.com/pyglet/pyglet
For Scratch, the pen tool extension works really well. I was just doing a demo on this for an elementary class the other day.
- scotty79 5y agoPyglet looks great, but drawing is done in OpenGL way. Is there a libraray that uses pyglet giving it the drawing interface more limilar to what other 2d APIs offer? Like the one suppoted by HTML Canvas tag? EDIT: Never mind. I just noticed pyglet.shapes offers something more palatable than OpenGL. :-) and doing stuff is pretty clean: import pyglet from pyglet import shapes batch = pyglet.graphics.Batch() circle = shapes.Circle(700, 150, 100, color=(50, 225, 30), batch=batch) square = shapes.Rectangle(200, 200, 200, 200, color=(55, 55, 255), batch=batch) window = pyglet.window.Window(960, 540) @window.event def on_draw(): window.clear() batch.draw() @window.event def on_key_press(symbol, modifiers): if symbol == pyglet.window.key.ESCAPE: window.close() pyglet.app.run()
- scotty79 5y agoAfter some experimentation I found out that pygame is even better them pyglet. I had multiple issues with pyglet with high monitor refresh rate, HDR and refresh rate mysteriously slowing down after I dragged the window around. While pygame works flawlessly.