Project 3

Pen plotter art

The Project

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.

What’s a 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!

Inspiration

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.

madison-axi library

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.

Installing the library

Open the command prompt on your classroom computer:

  • click the Windows icon on the bottom-left of the screen
  • type cmd
  • click Command Prompt

Install the library on your classroom computer:

  • type pip install --user madison_axi at the command line and hit enter
  • once the install is finished if IDLE is open, close it and open it again -- the library won't be available until you do this

This 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.


your program

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.


madison_axi library

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.


the graphics window / running your program

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.


Requirements

Your ART should be original and have an interesting pattern or design.

  • Think about what you have learned in Python so far and how you could incorporate it into your art.
  • Use randomness somehow in your program while keeping some sort of artistic structure: for example, draw circles of random sizes to make a larger circle, or draw a grid of random shapes in increasing sizes, etc.
  • It's fine to be inspired by someone else's art, just be sure to credit the artist in a comment with a relevant link on line 2 of your code.


Your CODE should follow the style guidelines and show how much you have learned.

  • Use a for loop (better: use the variable to vary something).
  • Use at least two functions to generate your art (better: more functions, some of the functions call each other); you can use as many functions as you like.
  • At least one of your functions must take input(s) and use those inputs to control something about the drawing: for example, draw_square(length), or draw_circle(x, y, radius), etc.


Submitting your project

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 .