Sunday, August 10, 2014

Processing Learning 3

float d = dist(100, 100, mouseX, mouseY);  // Calculate the distance between (100, 100) and (mouseX, mouseY)

dist():
float distance(float x1, float y1, float x2. float y2) {
float dx = x1 - x2;
float dy = y1 - y2;
float d = sqrt(dx * dx + dy * dy);
return d;
}

Append():
Processing, in fact, offers a set of array functions that manipulate the sie of an array by managing this process for you. They are: shorten(), concat(), subset(), append(), and expand(). In addition, there are functions for changing the order in an array, such as sort() and reverse().

append(): Each time the mouse is pressed, a new object is created and appended to the end of the original array.

Built-in Library:

  • Video: For capturing images from a camera, playing movie files, and recording movie files.

  • Serial: For sending data between Processing and an external device via serial communication.

  • OpenGL: For rendering a sketch with graphics acceleration.

  • Network: For creating client and server sketches that can communicate across the internet.

  • PDF: For creating high resolution PDF's graphics generated in Processing.

  • XML: For importing data from XML documents.


float r = 75;
float theta = PI / 4; // We could also say: float theta = radian(45);
float x = r * cos(theta);
float y = r * sin(theta);

No comments:

Post a Comment