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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

606<br />

directly within the code as comments. I recommend running the example first before<br />

going through the code. Happy motion painting!<br />

/* Motion Painter<br />

Ira Greenberg, April 17, 2006 */<br />

/* Begin declaring global variables above<br />

the setup() function. */<br />

int points = 5;<br />

/*parentNode[] array holds x <strong>and</strong> y position of<br />

center of moving brush shape.*/<br />

float[]parentNode = new float[2];<br />

/*shape[][] 2-dimensional array holds x <strong>and</strong> y position<br />

of up to 8 points making up the vertices of each<br />

brush shape. Each brush shape can have a minimum<br />

of 2 points or a maximum of 8 points.*/<br />

float[][]shape = new float[8][2];<br />

float shapeRadius = 10.0;<br />

float strokeAlpha = 255;<br />

float speed = 2;<br />

float rotation = 15;<br />

float rotationSpeed = 4;<br />

float xSpeed = 0.0;<br />

float ySpeed = 0.0;<br />

byte xDirection = 1;<br />

byte yDirection = 1;<br />

float strokeWt = 1;<br />

/*strokeColor[][] 2-dimensional array holds<br />

color values for each edge of the brush shapes.*/<br />

float[][]strokeColor = new float[8][3];<br />

boolean isWallSolid = true;<br />

int canvasWidth;<br />

int canvasHeight;<br />

PFont font;<br />

void setup(){<br />

size(600, 400);<br />

canvasWidth = width;<br />

canvasHeight = height-100;<br />

background(255);<br />

smooth();<br />

frameRate(30);<br />

/*Initialize parentNode to center of canvas, which

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

Saved successfully!

Ooh no, something went wrong!