34. GlossaryΒΆ

absolute path name

A way to name files in a file system by listing the folders that contain the file before the name of the file. For example, this is how an absolute path name would be written on Windows:

C:\Desktop\courses\fall2011\cmpt166\ball.gif

And on a Mac or Linux system:

/Desktop/courses/fall2011/cmpt166/ball.gif

Compare to relative path name.

alpha value

In RGB color, the alpha value of a color typically specifies the transparency of that color. For example, this sets the fill color of a shape to be 127, which results in a transparency of about 50%:

fill(0, 255, 0, 127);

In Processing, color alpha values range from 0 (totally transparent) to 255 (totally opaque).

applications programming

Writing programs intended to be used as applications by non-technical users. For instance, word processors, email clients, and almost all smartphone apps are example of application programs.

Compare to systems programming.

array

A contiguous sequence of 0 or more objects. For example, here are two arrays:

int[] ages = {18, 18, 17, 19, 20};
println(ages[3]);   // prints "19"


float[] dist = new dist[3];
dist[0] = 3.422;
dist[1] = 1.08;
dist[2] = 5.232;
assembly language
The lowest-level programming language that lets the programmer directly control the CPU and RAM. Assembly language programs are often quite efficient, and take up little memory. However, assembly languages vary among CPUs, and reading assembly language is relatively difficult.
assignment
See assignment operator.
assignment operator

The = symbol is know as the assignment operator in Processing. For instance, this line of code assigns the value -2.01 to variable y:

y = -2.01;

The assignment operator does not work like = in mathematics. For instance, you can write code like this in Processing:

y = y + 1;

This adds 1 to y, which is a useful programming operation. But in mathematics the equation y = y + 1 isn’t very useful because it is equivalent to 0 = 1 after you subtract y from both sides.

The Processing == operator works like the mathematical =. == is the boolean equality operator, and expression like x == y is a boolean expression that returns true if x and y` have the same value, and ``false otherwise.

base class
A class that is designed to be extended by other classes. Bases classes are often declared abstract so objects for them cannot be created using new.
binary digit
See bit.
bit

A bit is the basic unit of information in computing. A bit has two possible distinct states, often called 0 and 1. Two consecutive bits can represent four distinct states: 00, 01, 10, and 11. Computer’s process all information in terms of bits.

Bit is short for “binary digit”, and was coined by the mathematician John Tukey.

block of code
In Processing, a block of code consists of one or more statements grouped together inside a { and }. The statements are consistently indented so that they all start in the same column. If-statements, loops, functions, and classes all use blocks of code.
boolean

A data type having one of two values, true or false.

usage:

boolean b = true;
boolean c = false;
boolean expression

An expression that evaluates to either true or false. For example, these are all boolean expressions:

x < 1
y >= 4 + a
x == y
x - 1 != 2 * y
true
false
false || true

On the other hand, these are not boolean expressions:

x + 1
"Hello"
bounding box
The smallest rectangle that can be drawn around a graphical object (with sides parallel to the x-axis and y-axis). Often used to control the position and angle of the object.
braces
{ is an open brace, and } is a close brace.
byte
A byte is 8 bits.
character literal

A character in a program beginning and ending with a '. For example, these are all character literals:

'a'
'K'
'7'
'+'
'\n'
'\''

Note that '' is not a character literal: there is no such thing as an empty character (although there is such a thing as an empty string).

Be careful not to confuse character literals — which begin and end with ' — with string literals — which begin and end with ". For example, ‘A’ is a character literal, while “A” is a string literal.

class
A structure that lists all the variables and functions in a set of related objects.
code
Short for source code.
collection object
An object that stores groups of other objects. For example, an ArrayList<String> object stores Strings.
collision detection
See hit detection.
comment
See source code comment.
comparison operators
In Processing, the main comparison operators are >=, <=, <, >, ==, and !=.
concatenation

String concatenation is when two, or more strings, are combined to make a new string. For example:

String firstName = "Donald ";
String lastName = "Knuth";
String fullName = firstName + lastName;  // "Donald Knuth"
console
See console window.
console window
The window where print and println statements get printed. In the Processing editor, the console window is the small black space under the main editing window.
constructor
A special function that is called when an object is create using new. A constructor always has the same name as the class it is in, and it has no return type. Usually, a constructor initializes all the variables within an object.
copy constructor

A constructor that takes another object of the same type as input and makes a copy of it, e.g.:

class Point {
   int x;
   int y;

   Point(Point p) {  // copy constructor
      x = p.x;
      y = p.y;
   }
}
CPU
Short for central processing unit. The CPU is the “brain” of the computer, and is responsible for executing low-level instructions related to logic and arithmetic.
current working directory
See current working folder.
current working folder

When specifying the name of a file using a relative path name, the current working folder is the name of the top-most folder that will be searched.

Also know as the current working directory, or present working directory.

data structure
A way of storing organizing data stored in a computer. Common data structures include strings, arrays, objects, stacks, queues, and trees.
data type
See type.
default constructor

A constructor that takes no input parameters, e.g.:

class Point {
   int x;
   int y;

   Point() {  // default constructor
      x = 0;
      y = 0;
   }
}
directory
Another name for a folder.
dot notation

A way of accessing the variables and functions in an object. For example:

String s = "hello";
String t = s.trim();

The expression s.trim() uses dot notation to call the trim() function that belongs to s.

dot operator
See dot notation
easing
An animation technique where an animated object’s velocity is proportional to thing it is moving towards (or away from). For instance, an animated spaceship docking with a space station slows down as approaches the space station: it eases its way into the station’s docking bay.
empty string
The string "". It has 0 characters in it.
escape character

In a string, an escape character is a special code for a character that cannot be directly typed into the string. For example, \n is the newline character, and there is no standard symbol for a newline.

Even though an escape character is more than one character long, it only counts as one character in the string. For example, the string "a\nb\NC" is exactly 5 characters long.

When you print a string with \ns in it, they cause the cursor to move to the next line. For example, println("a\nb\nc") prints this on the console:

a
b
c

The most common escape characters are \n (newline), \\, \", \t (tab), etc.

file
A named collection of data on a disk.
file system
The files, folders, and software used to store and retrieve data on a computer disk.
float

A computer representation of a real number (i.e. a number containing a fractional part). e.g.:

2.0

3.14159

-33.333333333

usage:

int y = 3.0;

Note

when performing arithmetic on mixed types (e.g. int and float) processing will convert one of the types. This is known as implicit conversion

flow chart

A visual notation for describing the simple computer programs. For example, the following flow chart shows how Processings setup() and draw() functions are called:

Flow chart showing when setup() and draw() are called.
folder
A named collection of files and other folders.
for-each loop

A Processing construct that can be used to access every element in a “term:container object such as an ArrayList. For example, this code prints every string in names:

// names in ArrayList<String> object

for(String s : names) {
   println(s);
}

The : inside the loop header can be read as “in”.

for-loop

A Processing construct that repeats a block of code. For example, this code prints then numbers from 1 to 100:

for(int i = 1; i < 101; ++i) {
   println(i);
}
fps
Short for frames per second. See frame rate.
frame rate

The number of times per second that draw() is called by a Processing program. As long as it doesn’t take too long for draw() to run, Processing calls draw() about 60 times per second by default. The variable frameRate is an estimate of the current frame rate for a Processing program.

You can change the frame rate using the frameRate() function. For example, this sets the frame rate to be 30 frames per second:

frameRate(30);
frames per second
See frame rate.
function
A named block of code consisting of a function header and function body.
function body

The statements that get executed when a function is called. For example, the function body of pointInCircle is the code block after the function header (i.e. the first line):

boolean pointInCircle(float x, float y, float a, float b, float r)  // function header
{                                  //
  if (dist(x, y, a, b) <= r) {     //
    return true;                   //
  } else {                         //  function body
    return false;                  //
  }                                //
}                                  //
function header

See also function signature.

The first line of a function that declares the function’s return type, name, and input parameters. For example:

boolean pointInCircle(float x, float y, float a, float b, float r)  // function header
{
   // ... function body ...
}
function signature

Also known as function header.

The first line of a function that declares the function’s return type, name, and input parameters. For example:

int add(int a, int b) { // function signature
    // ... function body ...
}
gigabyte
A gigabyte (GB) is 1 billion bytes. Computer RAM is often measured in terms of gigabytes.
gigahertz

1 gigahertz (GHz) equals 1000 megahertz (MHz), or one billion hertz (Hz). One hertz means one cycle per second, and so 1 gigahertz means 1 billion cycles per second. If a computer CPU runs at a speed of 1 gigahertz, then that means it can do 1 billion low-level operations (like addition or multiplication) per second.

Modern CPU speeds are often in gigahertz. For instance, if your computer runs at 2.5 GHz, then it does about two and a half billion low-level operations per second.

global variable

A variable that can be accessed by any function. In Processing, global variables are variables defined outside of any function. For example, c is a global variable in the following program:

color c = color(255, 0, 0);

void setup() {
   size(500, 500);
   // ...
}

void draw() {
   // ...
}

Compare this to local variable.

grayscale
A restricted set of colors, often varying shades of gray. In RGB, gray colors have the form (n, n, n).
high-level programming language
A programming language, such as Processing, Java, C++, or Python, that lets programmers write code that looks somewhat like English.
hit box
A rectangle, usually drawn around an image, that is used to determine if the image has hit another geometric object. They tend not to be very accurate for curved shapes, and in more complex programs multiple hit boxes are sometimes used to more accurately cover an image. Hit boxes are a common solution to the hit detection problems.
hit detection
The problem of determining if two (or more) geometric objects intersect. Checking this depends on the objects involved, and in general is quite tricky to do correctly and efficiently. For many simple cases, though, such as rectangles, or points and circles, hit detection is straightforward.
if-else statement

An if-statement with an else clause, e.g.:

if (dist(mouseX, mouseY, x, y) <= radius) {
  ball_color = color(255, 0, 0);
} else {
  ball_color = orange;
}
if-else-if statement

An if-statement with an else if clause, e.g.:

if (d < 1) {
  moving = false;
} else if (d < easingLimit) {
  speed = d * maxSpeed / easingLimit;
}
if-statement

A kind of statement that makes a decision about whether or not to execute a block of code. For example:

if (x == 0) {
   println("x is 0");
} else if (x < 0) {
   println("x is negative");
} else {
   println("x is positive");
}
index variable

Usually, the variable declared inside a for-loop header. For instance, in the following code i is the index variable:

for(int i = 1; i < 101; ++i) {
   println(i);
}
infinite loop
See infinite loop.
inheritance
An object-oriented programming technique that lets you create new classes by extending old ones.
inner class
A class declared inside another class.
int

A computer representation of an integer.

usage:

int x = 3;
interpenetration

When two or more animated objects intersect. For example:

Interpenetrating ball.

Here we say that the ball interpenetrates the wall.

Interpenetration is not allowed when objects are meant to be solid. One common technique for fixing object interpenetration is to adjust the position of the objects so they no longer intersect.

kilobyte
A kilobyte (KB) is 1 thousand bytes.
library

A named collection of implemententations of a particular behaviour, providing and easly accessibly interface, making it easy for different programs to resuse.

For example, the Minim library provides programs in Processing with a way of manipulating audio.

local variable

A variable declared inside a function. In Processing, a local variable can only be accessed by code in the function that comes after the declaration. For example, in the following program c is a local variable in draw(), which means it can only be used in the body of draw():

void setup() {
   size(500, 500);
   // ...
}

void draw() {
   color c = color(255, 0, 0);
   // ...
}

Compare this to global variable.

logical operators
Processing has three main logical operators. Assuming a and b` are both :term:`boolean expression`\ s, then ``!a (not), a && b (and), and a || b (or) are also boolean expressions.
low-level programming language
A programming language, such as assembly language, that lets programmers directly manipulate the computer hardware. Such languages are often useful in systems programming.
mod operator
See remainder operator.
newline
See escape character.
object
Data that contains variable values and functions that can operate on those values. In object-oriented programming, new kinds of objects can be created by the programmer.
object-oriented programming
A popular style of programming that uses classes and objects to group together related variables and functions. This has proved to be a good way to design libraries of utility functions, and the resulting code is often relatively easy to read and maintain.
off-by-one error

A common programming error where the, typically, the value of a variable is thought to be one more, or less, than its true value. This often occurs in loops. For example, the following loop contains an off-by-one error:

int[] arr = new int[6];

for(int i = 0; i <= 6; ++i) {  // oops: i gets too big
   println(arr[i]);
}

This loop tries to access arr[6], which does not exist.

OOP
See object-oriented programming.
operating system
The set of programs on a computer that control its resources. For example, an operating system software is responsible for running programmings, and reading and writing files on disk.
origin
The point of intersection of coordinate axes. Alternatively, the point whose coordinates are all zero.
parallel program
A program that sometimes performs more than one action at a time. For example, using the Minim library Processing programs can play music and sound effects at the same time as drawing on the screen.
parameter
An input to a function.
pixel
The smallest changeable region color on a computer monitor.
present working directory
See current working folder.
primitive type
see primitive value
primitive value
In Processing, a primitive value is a value of one of the basic built-in types, such as int, float, char, color, etc. Importantly, you use the == operator to test if two primitive values are the same. To test if non-primitive values are the same (e.g. strings are non-primitive values in Processing), you usually use the .equals function that comes with the value.
procedural programming
A style of programming that emphasizes the procedures — e.g. statements and expressions — of programming. Compare this to object-oriented programming.
program
A series of instructions that tell a compute what to do.
programming language
An artificial language for telling computers what to do. Thousands of programming languages have been created over the years, although only a relatively few have been widely adopted.
pseudocode
Semi-formal English used to describe programs and algorithms.
radians

The natural unit for measuring angles and rotations. To convert degrees into radians, use this formula:

\textrm{deg} = \textrm{rad}\cdot\frac{\pi}{180^\circ}

It is already implemented in Processing as degrees, e.g.:

float rad = PI/4;
float deg = degrees(rad);
println(rad + " radians is " + deg + " degrees");

And this formula converts radians into degrees:

\textrm{rad} = \textrm{deg}\cdot\frac{180^\circ}{\pi}

It is already implemented in Processing as radians, e.g.:

float deg = 45.0;
float rad = radians(deg);
println(deg + " degrees is " + rad + " radians");
RAM
Short for random access memory. This is the computer’s main memory. The phrase “random access” means that any location in memory can be written to, or read from, at any time.
relational operators
See comparison operators.
relative path name
A way to name files in a file system. One folder is designated the current working folder, and all file names are assumed to be in that folder. Relative path names are usually shorter than absolute path names, and can be more easily re-used on file systems with different folder structures.
remainder operator

% is the remainder, or mod, operator, and the expression a % b evaluates to the remainder when a is divided by b. The expression a % b is often read as “a mod b”. It is usually assumed that both a and b are integers, and that b is both less than, or equal to, a, and greater than 0.

For example:

10 % 1 evaluates to 0
10 % 2 evaluates to 0
10 % 3 evaluates to 1
10 % 4 evaluates to 2
10 % 5 evaluates to 0
10 % 6 evaluates to 4
10 % 7 evaluates to 3
10 % 8 evaluates to 2
10 % 9 evaluates to 1
10 % 10 evaluates to 0
resolution
The width and height of a computer monitor (in pixels).
return value
The value calculated by a function. We say that this value returned to the point in the program where the function was called.
RGB
See RGB color.
RGB 3-tuple
see RGB triplet
RGB color
A popular computer color scheme where every color is represent as a triple of numbers of the form (r, g, b). For example, the RGB triple for orange is (255, 165, 0). The r, g, and b values specify the intensity of red, green, and blue respectively. In Processing, r, g, and b must each be greater than or equal to 0, and less than or equal to 255.
RGB triplet
See RGB color.
rotation
A function that moves a figure around a fixed point. Typically specified using an angle of rotation.
scaling
In graphics, scaling refers to the process of making an image bigger or smaller. Processing provides a scale function to do this, but you often get better results if you do the scaling use special-purpose image processing software like Photoshop.
scripting
A kind of programming that is typically used to automate repetitive tasks. Programs are called scripts, and they are often relatively short and easy to create as compared to non-scripting languages. An example of a popular scripting language is Python, which provides numerous practical code libraries that make it easy to automate all kinds of computer-related tasks.
sequential program
A program that performs one action at a time. Most of the programs we write in Processing are sequential.
sketchbook
The term Processing uses to refer to a folder that contains Processing programs. You can change the sketchbook folder in the Processing editor by going to the Preferences dialog box in the File menu (or by pressing ctrl-comma).
software
A collection of programs and related data.
source code
The textual instructions that make up a program. Source code is typically stored in a text file and edited with either a plain text editor, or a special-purpose programming editor that provides useful features such as syntax coloring.
source code comment

Text that appears in the source code of a program that is meant as a note to a reader of the source code. Comments have no effect on the program itself, and are automatically stripped out when the program is compiled.

Processing allows two kinds of source code comments:

// this is a single-line comment

/*
   This is a multi-line comment.
   It can span more than one line.
*/
sprite
An animated object.
sprite sheet
A collection of sprite images in a single image file.
statement
A single line of code such as a function call or assignment. In Processing, most statements end with a ;.
string
A sequence of 0 or more characters.
string literal

A string in a program beginning and ending with a ". For example, these are all string literals:

"mouse"
"Once upon a time ..."
"604-555-3536"
"X"
"1\ntwo\nthree"
"Her name is \"Mary\""
"\\n is a return character"
""
substring

A substring is a string of characters that is contained in another string of equal or greater length. For example, these are all substrings of the string “abcdef”:

""
"ab"
"def"
"bcde"
"abcdef"

Notice that by the definition, each string is a substring of itself, and the empty string is a substring of every string. The following are not substrings of “abcdef”:

"aab"
"defg"
"x"
syntax
The rules that determine what symbols go where in a program.
systems programming

Writing programs related to a computer’s operating system. Systems programs often do not interact with the user directly, and instead interface with the operating system. The Cs and C++ languages are popular choices for systems programming.

Compare to applications programming.

token

A programming language token is a string of 1 or more characters that has some special meaning in the language. For instance, these are all Processing tokens:

=
==
+
-453.2
dx
if
for
void
//
translation

A function that moves every point a constant distance in a specifed direction.

A figure translated in 2 dimensions
truth-table

A way of defining logical operators, e.g.:

a b !a a && b a || b
false false true false false
false true true false true
true false false false true
true true false true true
type

In Processing, the type of an object specifies what kind of object it is. For example, some of the built-in numeric types are int (for whole numbers) and float (for decimal numbers). Just by looking at types, Processing can often detect errors without having to run the program, e.g.:

float x = "3.14";  // type error: can't assign a string to a float
value
Things like numbers, strings, and objects. In Processing, all values have a type. For example, -65 is an int value, 3.14 is a float value, "cheese" is a string value.
variable

A named value. For example, this line declares n to be a variable of type int:

int n = 5;

Previous topic

33. Grading FAQ

Next topic

35. ArrayList functions