Processing 5

Within one of the final tutorials in which we would be working on pieces separate to our own works and ideas we began to focus on more advanced areas of the processing software. In this workshop Picture30we began to look at using agents, how we then create them into a class and then used this class to create and overall array. The first half of the lecture the lecture focused on creating a class of agents. The top of the class we declare the points which will dictate the positioning, size and colour of each individual agent and how this will then be randomize through the class so that each time the most is clicked it will produce a new agent of a different colour and position on the screen. As we move further down the code these points are then given their roles as colours and integer, this’ returns this instance of the class agent and is use to address the class field, this point is then labelled as the constructor. The Void update section then uses the positioning declared in the previous points to continuously update the movement of the agent between the spaces of -1 to 1 so that when drawn on screen the agent will then ‘jiggle’ on the screen.  In the final void draw section this finally declares the agent within the canvas itself and draws it to screen using the previous code to dictate the size, positioning and colour within the screen.

Picture31The secondary part of the lecture then focused on using the now declared class of agents to create an image that when clicked on an new agent will appear in randomised colours. To create this we must first input an array list of the agents within this new page of code. We then add the basic areas surrounding the size within the void setup, as well as declaring the new array list of agents from the previous page. Then with the void draw section we then input the background colour, which the iterate through our Array List of agents, getting each in turn and calling its update and draw method. This then uses the individual elements of the previous section and applies it to the current code, creating a temporary variable location, applies the updating method of movement and then draws the agent to screen.  Within the final section we then apply the code that allows the now declared agents to be placed on the screen according to where the mouse clicks. Using the NEW and agent A declarations we can create the instance in which the agent is drawn onto the  screen, we then add our previous created agent to the variable as a parameter. Finally by using the println we are able to see how each time the page is clicked the variables size changes.Picture33Picture32Picture34

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s