All course materials and instructions are available in Canvas this year.
For this project, you’ll use IDLE to write a program that generates cool art that can be drawn on a pen plotter. You’ll also learn how to install and use the Python library that controls the pen plotter.
A pen plotter is a robotic gadget that holds a pen and draws stuff based on commands sent to it by a computer. The particular pen plotter we’ll be using is called an AxiDraw, and it looks like this:
The basic idea is that the device holds a pen, we put a piece of paper under the pen, and you write a computer program that tells the plotter to move the pen around so that it draws stuff on the piece of paper.
If you’ve used the Watercolor Bot, this is a lot like that - except it’s simpler, because you don’t have to worry about writing code to wash the brush and dip it in different kinds of paint!
Here’s some cool stuff that people have drawn with an AxiDraw:
Notice how some of these (like the third one) have an element of randomness to them. Think about how you could incorporate randomness into your code so that it draws something different every time it’s run. Just be sure that that your program stays within the bounds of the page!
For more examples, see:
Click around on those links and explore, you’ll see a lot of cool art that was generated using a bit of randomness.
Our volunteer and expert Python programmer, JR Heard, has written a library called madison_axi
that will let you write Python code to control our classroom’s plotter. When you run your program on your computer, it’ll draw a preview of what you can expect to see on the plotter; once that preview looks the way you want it to, you can submit your program and we'll run it on the plotter.
Open the command prompt on your classroom computer:
cmd
Command Prompt
Install the library on your classroom computer:
pip install --user madison_axi
at the command line and hit enterThis installation process is slightly different from what the QuickStart page says. If you don’t include the --user
in there, it won’t work, because you don’t have administrator access on these computers.
Start to get to know the library by reading the QuickStart guide. Read the example program on that page and make sure you understand it.
There are some more example programs if you want to read those too - spiky_circle.py
is my favorite, try running it on your computer later on once you’re all set up.
In a new IDLE file, start by importing the AxiDraw library at the top of your code, like this:
from madison_axi.axi import *
After that, you can call functions from the library like this:
initialize()
# Make a horizontal line
move_to(0, 0)
point_in_direction(0)
pen_down()
move_forward(50)
cleanup()
NOTE: You must call initialize()
at the start of your program and cleanup()
at the end of it.
Controlling the plotter is a lot like controlling a turtle - the library gives you access to functions like turn_right(45)
, turn_left(90)
, move_forward(100)
, etc. This will feel very familiar from previous assignments.
This page has a list of all of the functions that the library gives you. Read the whole page, there aren’t very many functions. You might be able to get away without get_position()
, get_y()
, and get_x()
, but you’ll probably use all of the other ones.
When you run a program that uses this library, you’ll see a graphics window appear on your screen, and it will draw a preview of what your program would do on the plotter.
The window is 1040 pixels wide and 784 pixels high. This file will draw a border that is -500 to 500 in the x direction and -370 to 370 in the y direction.
The window is that size on purpose! DO NOT RESIZE THE WINDOW and make sure that your program doesn’t draw stuff outside the bounds of that window, or it won’t get drawn on the plotter’s piece of paper.
Your ART should be original and have an interesting pattern or design.
Your CODE should follow the style guidelines and show how much you have learned.
draw_square(length)
, or draw_circle(x, y, radius)
, etc. Before submitting your project, make sure to test your program a bunch of times to make sure it works! Review the rubric, and remember to follow this class’s style guide.
On Google Classroom, submit your program in a file called plotter_YOUR NAME_Title of Your Art.py
. For instance, I might submit a file called plotter_Tamara_Spiral Squarecase.py
.
On the first line of that file, write a comment with your name on it, like this:
# Tamara O'Malley
The projects in this class were created with a LOT of help from JR Heard, a TEALS volunteer at Madison, 2017-2019. His version of this project lives at https://blog.jrheard.com/python/password-generator .