Homework due Monday October 30: Recreate a computer art piece in Processing

For this assignment, my inspiration comes from a project in Computer Arts (issue August 2017). Here is the link to the project. In this work, they use lines to connect the points in the grid so that they can draw something. 

In my work, I draw 4 squares, then points inside of them, then random lines that connect 2 points in each square. Here is the result. 

Throughout the process of creating art piece,  I found myself struggling with how to create a parameter, or a set of values that random() can choose from. Usually we use random() to pick out values from a continuous set of values. For example: random(0,255) pick out any value from 0 to 254. However, in my case the points in are not right next to each other, thus in order to draw random lines between them, I have to create a set of values of the x and y coordinates of points in a particular square, then use that set to draw the lines. To do this, I use Arrays to store x and y values from points in each square. 

I also discovered that for example, random(0,255) picks out values from 0 up to, but not including, 255. I did not know this before, so when I pick random numbers out of my array, which has 6 values, numbered from 0 to 5, I wrote my code as numbers_xposPoint[ (int) random (1,5)] and created the error Array Index Out Of Bounds Exception , which made Processing stop responding and my computer crash.

CODE

In addition to this most basic version, I also created some variations of it:

Variation 1: 

The program does not stop drawing at 25 lines each square, but continues to draw. Each time you press ‘c’, the new lines change to another color

 

Variation 2: 

Instead of 4 squares, there are 400 squares. This time I have to use calculations to create x and y positions of the squares

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *