VisPy is quite an interesting tool. They say it is for “scientific visualization”. Here is an example of that. I took a demo from their github page and added a little code to generate a sinewave. The cool thing is that the graph, scaling, panning, zooming, and redrawing all come out of the box.
I previously wrote about installing VisPy. Thanks to the great efforts of some unnamed people, Python on Windows is really working nicely now.
Here is a screenshot:
Here is the code:
Here is an example of a moving 2D sine wave using Python 3, PyGame, and PyOpenGL. See a https://blog.gahooa.com/2018/02/11/pygame-and-opengl-on-windows-10/ for how to install them.
This sample program is designed to have a 100×60 unit working area with a 10 unit buffer around the edges. You can see the axis in the lower-left (0,0) where Y+ is up, and X+ is to the right.
The structure of the program was created to make it super easy to work on the “guts” of the graphics without getting it confused with the “bookkeeping” end of OpenGL or PyGame.
Note: the glOrtho() command is how 2D “parallel perspective” is setup. It defines the left, right, bottom, top, near plane, and far plane. Because it is parallel, there is not the notion of a “camera” per-se, but rather section of the plane that should be viewed. Documented here:
Here is the code!