Summit Middle School classes for Andrew Busch
Andrew Busch - Summit
  • Home
  • Algebra 1
    • Alg 1B - Last Week
    • Alg1B 14 HW - Intro to Functions
    • Alg 1B 11 - Rational Expressions
    • Alg 1B 12 - Radical Expressions
    • Alg 1B 10 v2.0 - Quadratic Functions >
      • 10b Graphing with Pennies - Desmos Tutorial
      • 10i Snowboard Quadratic - Alg1B
      • 10 Quadratics Project
    • Alg 1B 10 Book - Factoring Quadratics
    • Alg 1B 9 - Exponential Functions
    • Alg 1B 8.5 - Representing Data
    • Alg 1B 13 - Inequalities
    • Alg 1B 8 - Best Fit Lines and Linear Regression
    • Alg 1B 7 - Linearity
  • Geometry
    • Geom Last Week
    • Geom 12 - Probability
    • Geom 11 - Circumference, Area, Volume
    • Geom 10-Circles
    • Geom 9 - Right Triangles and Trigonometry
    • Geom 8 - Similarity
    • Geom 7 - Quadrilaterals and Other Polygons
    • Geom 6 - Relationships Within Triangles
    • Geom 5 - Congruent Trianlges
    • Geom 4 - Transformations
    • Geometry 3.5 - Constructions
    • Geom 3 - Parallel and Perpendicular Lines
    • Geom 2 - Reasoning and Proofs
    • Geom 1 - Basics of Geometry
  • Programming
    • Directions for Sharing Programs with Me
    • Hour of Code
    • Intro to Python >
      • Installing and Using Portable Python
      • Introduction to Programming
      • Interactive Storyteller
      • Sophisticated Calculator
      • Getting Started with Games
      • Word Length Frequency
      • Substitution Cipher
      • Simple Game of Paddleball
      • Animating Many Objects
      • Accelerator
      • Applying Trigonometry
      • GIFs
      • Programmatic Art
      • Battleship
      • Pong
      • CodeCademy.com Suggested Work
      • Python Resources
    • Advanced Python >
      • Python Installation
      • Review of Intro to Programming
      • Objects and Classes >
        • More on Classes: Functions, Methods, Inheritance
        • Quadrilaterals
      • tkinter >
        • Paddle Ball
        • Light Bike
        • Frogger
        • Snake Game
        • Breakout
      • Reading and Writing Files
      • Directories and Importing Modules
      • Raspberry Pi
      • API's
      • Python Puzzles
  • Clubs
  • Graphing Calculator
  • PARCC Practice

Programmatic Art

The resources on this page were originally created by Dr. Aaron Bradley of Summit Middle School. I've done some reformatting to add clarity but that is about it. Enjoy!
One fun thing to do with graphics is to make programmatic art.  When randomness is added, things get even more excited: you program an overall theme, but each execution of the program creates something new.

Consider the following program:
from sgfx import *
import random

w = Window()

colors = ['white', 'black']

# Create concentric circles whose colors are selected randomly.
for r in range(400, 0, -10):
    w.circle(250, 250, r, color=random.choice(colors))

# Create 3D-looking circles at random places with random radii.
for i in range(20):
    x = random.randint(0, 500)
    y = random.randint(0, 500)
    r = random.randint(0, 50)
    w.circle(x, y, r, color='black')
    w.circle(x+3, y+3, r, color='red')

w.run()
The effect is quite charming, in my opinion:
Picture
Each execution creates something a little different.
Here are some ideas to get you going on making your own programmatic art:
  • Use for loops and randomness (especially random.randint(lo, hi) for choosing values between lo and hi) to create many instances of objects at random locations and with random dimensions.
  • Use arrays of colors and random.choice(colors) to select colors randomly.  More is not always better.  My artwork, which is not too shabby, uses only three colors to good effect.
  • Apply math: combining loop variables with polynomial functions works well, e.g.,

    for i in range(10):
        w.circle(10*i, 20*i, 10*i)
Have fun!

Powered by Create your own unique website with customizable templates.