P5 is sort of Python ‘clone’ of Processing, that doesn’t actually use Processing to generate visual output. So, you may wonder: what’s the difference between p5 and Processing’s Python Mode? Python Mode ‘speaks’ directly to Processing it’s as close as you can get to pure Processing without writing Java, because all of your Python instructions are translated into instructions for Processing to carry out. There’s also a Python Mode for Processing, which I have written about extensively. P5 – not to be confused with p5.js – is a Python package based on the core ideas of Processing. It’s a stand-alone program that you simply run directly off your USB drive, or from wherever you choose to copy it to your computer (i.e. Portable ApplicationsĪ ‘portable’ application is one that does not include an installer. It’s multi-platform (Windows, Mac, Linux), open-source, and there’s a portable version too. The Thonny user interface is stripped back, but you can display several extra panels, like a panel to list your variables, an outline panel for your functions, an object inspector, an interactive debugger, a shell, a plotter, and more. In a downloadable zip file, less than 30 MB in size, you get a neat editor bundled with Python (version 3.7 at the time of writing). Thonny offers a quick and easy way to get coding in Python. If you haven’t heard about Thonny, it’s a Python IDE catering to any beginners looking to dabble in Python. The process is similar for Mac and Linux setups, although I will not cover the procedure for these platforms. This post covers how to roll-your-own portable Thonny + p5 IDE for Windows computers. This is quite different from p5 – like Processing.py, py5 also leverages Processing’s core libraries. I’ve written a more recent post on combining Thonny and py5. This Thonny-p5 combo is also handy for teaching programming in computer labs where students cannot install software, or any situation where you’d prefer to run an application in a portable fashion. There are situations where you may prefer to use p5 over Processing Python Mode / Processing.py, which I discuss in this post. I may also cover some of the others later on.You can combine Thonny and p5 for a Processing-esque, Python 3 development environment that runs off a USB drive. You can find more in the PyGame documentation. There are a few other drawing functions, though these are the ones that I find myself actually using. (if you don't understand this, revisit some of the earlier tutorials.) Now for some canned stuff to make our game actually run: This function asks where to draw, what color, and then asks for a long tuple, of tuples, containing the points of the polygon. There is another parameter that you can add which is width. This function asks where to draw, what color, what is the center point of the circle, and what is the radius. This function asks where to draw, what color, and then asks for a final tuple that contains: the top right x and y, followed by width, then height. We've already extensively covered the drawing of rectangles in this series, but this specific "drawing things" tutorial wouldn't be complete without it. The function just asks where do we want to draw it, what color do we want it, and then we specify the two coordinate pairs that we want to draw a line between. So, we specify pixAr, which means the pixel residing at (10,20), then we're able to re-assign it. So what this function does is it returns the pixel array of the specified surface (which is the entire display in our case). Typical stuff above, now let's cover what would be used to draw a pixel:Īlright, so what have we done above? What we're doing is assigning the entire pixel array to a value, referencing it using pygame.PixelArray. We can do things like draw specific pixels, lines, circles, rectangles, and any polygon we want by simply specifying the points to draw between. In this PyGame and Python programming tutorial video, we cover how to draw shapes with PyGame's built in drawing functionality.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |