Lynda | Processing Tutorials

Today Ive been doing more work on variables and mouse tracking. Im still trying to get my head around variables, I get the simple stuff its just the divides and “Int” commands that are defeating me, thats next on my list!
Using lynda.com I have been able to code a simple mouse tracking programme off by heart (I promise!). This programme simply allows you to draw lines with rectangular pivots with NO background reset.

Lynda.com is proving a massive help to me with this type of coding, there are over 7 hours of tutorials which includes a lot more than Ive covered as of yet.

Below is the programme I created:

void setup(){
  size(600, 600);
  smooth();
  frameRate(8);
  background(255);
}

void draw(){
  noStroke();
  fill(220, 0, 0);
  rect(mouseX, mouseY, 10, 10);
  fill(120);
  rect(pmouseX, pmouseY, 10, 10);
  stroke(9);
  line(mouseX, mouseY, pmouseX, pmouseY);
}

This program draws continuously with the background being redrawn each frame. A square is drawn at the location of the mouse 8 times a second according to the frame rate. A line is also drawn in relation to the mouse cursors location. In the future I will be looking at more complex code which involve variables and other functions.

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