Drawing with Code ================= Up through the mid-20th Century, software was written by punching holes in cards in specific patterns and feeding those cards into a computer in a specific order. .. figure:: images/drawing/computerPunchCards.jpg :width: 640px :alt: A woman looking at computer punch cards Computers were largely used for analyzing data and calculating mathematical problems. Yet, a little over 200 years ago, a precursor to the modern computer was used to create art and used punched cards to do so. The `Jacquard Loom `_ was a 2-story tall loom that was used to create elaborate weavings and used holes punched in cards in specific patterns and feeding those cards in a specific order to create those beautiful patterns. .. figure:: images/drawing/jacquardLoomCards.jpg :width: 640px :alt: A feed of punched cards for a Jacqaurd Loom Art and computers go way back. One of the earliest programming languages created for learning how to program was `Logo `_, released in 1967. .. figure:: images/drawing/LOGO.jpg :width: 640px :alt: An example output of a Logo program Introduced with the Logo programming language, was the idea of a Turtle as a robot to draw out the programmed image. The image is programmed as a series of moves and turns with the "pen" up or down on the "paper" and drawn accordingly. .. figure:: images/drawing/Turtle-animation.gif :width: 256px :alt: An example of a turtle program drawing a multi-pointed star Image courtesy of `Wikipedia `_. An animation that shows how the turtle is used to create graphics by combining forward and turn commands. (This is not actual Logo, but pseudo-code Logo.) `CC by SA 4.0 `_ Today, one might see the same kind of programming on the `Code.org `_ implementation of `Hour of Code `_. .. figure:: images/drawing/codeDotOrgMaze.jpg :width: 225px :alt: An example of a code dot org maze that has roots in Logo In `Scratch `_, we can draw using a Logo-like syntax. If you imagine the screen as paper and the sprite as the pen, "pen up" and "pen down" are concepts that are not that far fetched. In Scratch, we have "pen" options like "erase all," "pen up," "pen down," and "pen color." We can move a penned sprite 300 steps, turn 181 degrees, move 300 steps, and keep repeating. Example: `Colorful Circle Using Straight Lines `_ .. figure:: images/drawing/scratchPen.png :width: 640px :alt: Example code in Scratch for drawing a solid circle What do you think you can draw with a coded pen and a few simple commands? **************** Example Projects **************** - Scratch: `Pen Experiment `_ - Scratch: `Laser Cat `_ - Scratch: `Colorful Circle Using Straight Lines `_ ************* Project Ideas ************* - Draw polygons - Random art generator - `Cycle game `_