04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

120<br />

experience, which I know might sound odd to some of you. I did enjoy the class, <strong>and</strong> the<br />

professor tried to find some relevant connections, but that old dread came back in spite<br />

of the fact that I wasn’t even enrolled in the class, not to mention that I already had my<br />

degrees <strong>and</strong> a job. I especially found the tests disagreeable, where rigid constraints of time<br />

<strong>and</strong> a very limited solution set took most of the joy away. Ironically, I love trying to solve<br />

complex technical <strong>and</strong> analytical problems, as one finds continuously in programming.<br />

However, in programming, as opposed to a math class, technical problems are directly<br />

linked to the process of creating. Rather than having to plot some nondescript curve I<br />

could care less about (with little or no aesthetic payoff), I’d prefer to create an aesthetically<br />

based organic form, generated through a series of curve expressions. In addition,<br />

coding allows you to chart your own procedural course when solving a problem. For<br />

example, five different coders can each solve the same problem five different ways. I<br />

believe this type of flexibility is essential to the creative process—whether you’re painting<br />

a tree or creating a series of mathematical expressions to plot a tree.<br />

For your purposes, you only need a small part of math, <strong>and</strong> mostly pretty basic stuff.<br />

However, programming is really a form of applied math—a very creative form! If you want<br />

to move something on the screen, change the color of a pixel, or have the user interact<br />

with one of your <strong>Processing</strong> sketches, you need to deal with coordinates <strong>and</strong> usually simple<br />

addition, subtraction, multiplication, or division. For example, if you create a virtual ant<br />

<strong>and</strong> want it to w<strong>and</strong>er around the sketch window, avoiding some obstacles <strong>and</strong> searching<br />

for food, you need to continuously add values to the mouse’s x <strong>and</strong> y coordinates <strong>and</strong><br />

keep checking if the ant’s coordinates are interfering with either the obstacle or food<br />

coordinates. If you want the food to slowly disappear as the ant eats it, you can slowly shift<br />

the value of the pixels making up the food to the background color of the screen. This section<br />

is going to take a quick look at basic math utilized in graphics programming. The<br />

material should be viewed more as a math primer than a proper elucidation of this material.<br />

If you don’t fully get it here, don’t panic—it will be revisited later on. Some of these<br />

concepts are also exp<strong>and</strong>ed upon in Appendix B.<br />

Elementary algebra<br />

Algebra is old. It has been used continuously <strong>and</strong> developed for over 3,000 years, with early<br />

contributions made by cultures worldwide including the ancient Egyptians, Babylonians,<br />

Greeks, <strong>and</strong> Chinese. Algebra was first introduced into Europe in the beginning of the 13th<br />

century by Leonardo Fibonacci of Pisa. Fibonacci got famous for trying to figure out the<br />

breeding capacity of rabbits. What he realized was that there is a predictable sequence of<br />

numbers, based on a simple rule, connected to the rabbits’ breeding rates. In fact, this<br />

numeric progression is not only tied to rabbit breeding, but tree growth, numbers of<br />

petals on a flower, the spiral in the golden section, <strong>and</strong> many other natural phenomena. To<br />

learn more about Fibonacci <strong>and</strong> his rabbits, check out www.mcs.surrey.ac.uk/Personal/<br />

R.Knott/Fibonacci/fibnat.html#rabeecow.<br />

The actual word algebra comes from a ninth century Persian treatise, written by<br />

al-Khwarizmi (mentioned in Chapter 2 in the discussion about algorithms). Al-Khwarizmi is<br />

widely hailed as the father of algebra (as well as one of the greatest math geniuses of all<br />

time). Al-Khwarizmi, or algoritmi, as his name translates into Latin, is where the word algorithm<br />

comes from. Elementary algebra is absolutely fundamental to programming. In many<br />

ways, programming is algebra. However, programming is the kind of algebra you do but

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!