Saturday, April 06, 2013

Pretty Graph

Create colorful images by slightly modifying standard graphing techniques

Description

Doing some simple math trickery you can map a standard 2D graph into one that fills the entire 2D plane (i.e. a picture instead of lines). The shape of the objects stays the same provided you are working in the same geometry. So assume you have some function y = f(x) rewrite it as c = f(x) + y and then have some sort of mapping function such that g(c) = (r,g,b) or whatever color scheme you want. This will force the shape to repeat over the plane you are projecting onto, although scaling factors can become an issue.
For a simple example y = x is a straight line, transforming this into c = x + y and letting g(c) = (c%255, c*2 %255, c*3 %255) yields the following picture of repeated lines with a 1:1 slope

This works for any such equations, for example a circle x^2 + y^2 = c we get repeated circles

   
Some other examples:
  



   

Also from the more complicated original Haskell version:

Source Code

https://github.com/plurSKI/prettyGraph

No comments: