To calculate the midpoint of a line, use the following formula to calculate the x and y midpoints: # Middle of line # midpoint = (xM, yM) xM = (x1 + x2)/2 yM = (y1 + y2)/2 Then the midpoint coordinates (xM, yM) can be used to draw an ellipse on the line. For example: … Continue reading Processing.py: How to calculate the midpoint of a line
Python
WordPress: How to create a Table of Contents page with Python
What I wanted to create was a dynamic Table of Contents page where I could have a listing of all of my published articles, organized by category, and sorted such that categories with the most posts appear first, and the posts under each category are listed from most recent at the top to oldest at … Continue reading WordPress: How to create a Table of Contents page with Python
Python on the web: How to get a list of all available Python modules
If you want to get a complete list of Python modules available on your web host, you can do so with the following code: I saved the above code as a CGI script called “available_modules.py” and uploaded it to my website cgi-bin. Here is what the code produces, shown below in an iframe: For more … Continue reading Python on the web: How to get a list of all available Python modules
Python: How to print function details iteratively using inspect and getmembers
As described in a previous post, the help() function is great for seeing details about any given module function, one at at time. Python: How to use the built-in help( ) and dir( ) functions For example: print help(imageio.mimsave) However, sometimes we want to see details for all of the functions in an imported module. … Continue reading Python: How to print function details iteratively using inspect and getmembers
Processing.py: How to create grid square patterns and digital camo
Continuing the Processing.py series, this article demonstrates how to use a slight variant of the 10 PRINT example to build a grid pattern design made up of squares of differing sizes and colors. This technique can also produce digital camo (camouflage) patterns! For the previous entry in the Processing.py series, see this page: Processing.py: How … Continue reading Processing.py: How to create grid square patterns and digital camo
Processing.py: How to implement 10 PRINT
Continuing the Processing.py series, this article demonstrates how to implement ’10 PRINT’ to create interesting line images. 10 PRINT is an old Commodore 64 one-line program written in BASIC that looks like this: 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 For more information, see 10print.org. For the previous entry in the Processing.py series, see this page: Processing.py: … Continue reading Processing.py: How to implement 10 PRINT
Processing.py: How to use shapes, placements, and colors
To continue the series of how to use Processing.py, this article demonstrates how to use basic shapes, placements and colors. For the previous entry in the Processing.py series, see this page: Processing.py: How to draw lines and use mouse events This code demonstrates the use of lines, rectangles, ellipses, colors and placements by sketching a … Continue reading Processing.py: How to use shapes, placements, and colors
Python: How to generate animated .gifs
The below code can take in a list of consecutive image files and stitch them together to create an animated .gif file. It requires the imageio module. The path to the consecutive image files is set in the image_path variable. The full path to the name of the .gif file to be built is passed … Continue reading Python: How to generate animated .gifs
Processing.py: How to draw lines and use mouse events
Building on the first post about using Processing.py (shown in the table below), this post will demonstrate the basic structure of a Processing.py program, how to draw lines, and understand some other basics of the Processing.py programming language. For the previous entry in the Processing.py series, see this page: Processing.py: Getting Started Example 1: Drawing … Continue reading Processing.py: How to draw lines and use mouse events
Processing.py: Getting Started
Getting started with processing.py, this article follows the instructions found here: http://py.processing.org/tutorials/gettingstarted/ The first step is to download the processing IDE here. Once downloaded create a “processing_py” folder on your desktop and drag the “processing-3.3.6” folder from the .zip into the new folder. Inside this folder, click the processing.exe file and the IDE will open. … Continue reading Processing.py: Getting Started