---
title: 'Linear Modulus Art'
url: 'https://blog.recursiveprocess.com/2015/04/28/linear-modulus-art'
markdown: 'https://blog.recursiveprocess.com/2015/04/28/linear-modulus-art.md'
date: '2015-04-28'
description: "I saw this fantastic webpage a couple of months back. Tons of fun. I took that idea and made a gif\_for my weird art Tumblr, Recursive Processing. \_ Here’s the processing.org\_code and the live (and smoother) version, and here’s the more fun version that is interactive based on the…"
taxonomy:
  category:
    - blog
---

# Linear Modulus Art

### [Linear Modulus Art](https://blog.recursiveprocess.com/2015/04/28/linear-modulus-art)

   April 28, 2015, 12:00 am  

I saw [this fantastic webpage](http://stephanainley.com/shapes2/#) a couple of months back.

[![Screenshot 2015-04-28 at 11.30.56 AM](https://blog.recursiveprocess.com/wp-content/uploads/2015/04/Screenshot-2015-04-28-at-11.30.56-AM-1024x439.png)](http://stephanainley.com/shapes2/#)

Tons of fun. I took that idea and made a gif for my weird art Tumblr, [Recursive Processing](http://recursiveprocessing.tumblr.com/).

[![tumblr_nm56rdMlvl1uppablo1_r3_400](https://blog.recursiveprocess.com/wp-content/uploads/2015/04/tumblr_nm56rdMlvl1uppablo1_r3_400.gif)](https://blog.recursiveprocess.com/wp-content/uploads/2015/04/tumblr_nm56rdMlvl1uppablo1_r3_400.gif)

[Here’s the processing.org code and the live (and smoother) version](http://www.openprocessing.org/sketch/192120), and [here’s the more fun version that is interactive based on the mouse position](http://www.openprocessing.org/sketch/192276) (some interesting polar math is involved here, x = r cos (theta) and y = r sin (theta) ).

These all work on the same principle, take a bunch of points around a circle, and shift them around the circle based on a linear function. If the output is too large, then they wrap around (clock math). The formal name for this idea is modular arithmetic, a very useful concept in computer programming. A quick example: Take an input value of x = 120, and a function of y = 3x + 20 (mod 360). y = 3 (120) + 20 (mod 360) = 380 (mod 360) = **20** (the remainder after dividing by 360). So make a line between 120 on the circle and 20. The resulting image after calculating 360 different points for y = 3x + 20 is:
![Screenshot 2015-04-28 at 11.44.15 AM](https://blog.recursiveprocess.com/wp-content/uploads/2015/04/Screenshot-2015-04-28-at-11.44.15-AM.png)
But this concept is more difficult to grasp with the unusual step of graphing the points around a circle.

## Separate Input from Output

Lets go to a more straightforward representation. [Here’s an interactive that might help](http://www.openprocessing.org/sketch/196793).
[![Screenshot 2015-04-28 at 11.50.06 AM](https://blog.recursiveprocess.com/wp-content/uploads/2015/04/Screenshot-2015-04-28-at-11.50.06-AM.png)](http://www.openprocessing.org/sketch/196793)
So, this is just about the least interesting function, y = x (mod 10). So if x = 3, then y = 3 + 0 (mod 10) = 3. So draw a line from 3 to 3. Try the interactive yourself, click to change the function and see how it changes the picture.

Here’s another boring function: y = 0x + 0 (mod 10).
![Screenshot 2015-04-28 at 11.50.51 AM](https://blog.recursiveprocess.com/wp-content/uploads/2015/04/Screenshot-2015-04-28-at-11.50.51-AM.png)

Ok, lets get to the interesting stuff, y = 7x + 8 (mod 10). Take x = 4, so y = 28 + 8 (mod 10) = 36 (mod 10) = 6. Draw a line from 4 to 6.
[![Screenshot 2015-04-28 at 11.50.20 AM](https://blog.recursiveprocess.com/wp-content/uploads/2015/04/Screenshot-2015-04-28-at-11.50.20-AM.png)](https://blog.recursiveprocess.com/wp-content/uploads/2015/04/Screenshot-2015-04-28-at-11.50.20-AM.png)

Here’s another interesting picture:

[![Screenshot 2015-04-28 at 11.51.45 AM](https://blog.recursiveprocess.com/wp-content/uploads/2015/04/Screenshot-2015-04-28-at-11.51.45-AM.png)](https://blog.recursiveprocess.com/wp-content/uploads/2015/04/Screenshot-2015-04-28-at-11.51.45-AM.png)

If you really enjoy the picture that you’ve made then you can get a high definition version (5k by 5k) by copying the code, installing [processing.org](http://processing.org/) and clicking [any key](http://s2.quickmeme.com/img/be/be1086cd20c8c02ae8eeac16defcda450fac5f7cf367b9b9da04567aae72218e.jpg). The image will be in the same file as project. Very good for printing in large form if you’re lucky enough to have a big printer.

> New artwork in the classroom today. Told you I'd be dangerous when I figured out how to use the plotter. [pic.twitter.com/479YZnWNdy](http://t.co/479YZnWNdy)
> 
> — Dan Anderson (@dandersod) [April 24, 2015](https://twitter.com/dandersod/status/591672629083406336?ref_src=twsrc%5Etfw)

[Here’s a much more interactive version of this same concept. The mouse’s horizontal direction changes the slope of the line, and the vertical direction changes the offset (y-intercept)](http://www.openprocessing.org/sketch/193742).

## Questions For You

How can I bring this into the math classroom?

Where does this fit?

Is modular arithmetic in anyone’s curriculum? If not, why not?

Should I (or you) put together a non-linear version? Exponential, powers, logarithmic?

Other thoughts?

 [ Next Post](https://blog.recursiveprocess.com/2015/05/19/tracking-venus-and-earth-over-8-years) [Previous Post ](https://blog.recursiveprocess.com/2015/04/17/the-mandelbrot-set-viewed-through-precalculus)

#### SimpleSearch

Bootstrap Theme for [Grav](http://getgrav.org)

---

## Navigation

- Parent: [A Recursive Process](https://blog.recursiveprocess.com/index.md)
- Previous: [Tracking Venus and Earth over 8 years](https://blog.recursiveprocess.com/2015/05/19/tracking-venus-and-earth-over-8-years.md)
- Next: [The Mandelbrot Set Viewed through Precalculus](https://blog.recursiveprocess.com/2015/04/17/the-mandelbrot-set-viewed-through-precalculus.md)
