- Transition to Processing
- Primitive Operations
- Algorithms
- Variables
- Debugging in Processing
- Conditions
- Loops
- Functions
- Scope
- Compound Data
- Reference Semantics
- Refactoring
- Transition to Java
- Debugging in Java
- Unit Testing
- Classes - Writing your own Types
- Classes - Functions inside objects
- Recursion
- Lists
- Searching
- Lists ArrayLists vs Recursive Data

- Logic and Proofs
- Relations
- Mathematical Functions
- Matrices
- Binary Numbers
- Trigonomtry
- Finite State Machines
- Turing Machines
- Counting - Inclusion/Exclusion
- Graph Algorithms

- Algorithm Efficiency
- Algorithm Correctness
- Trees
- Heaps, Stack, and Queues
- Maps and Hashtables
- Graphs and Graph Algorithms
- Advanced Trees and Computability

- Command line control
- Transition to C
- Pointers
- Memory Allocation
- IO
- Number representations
- Assembly Programming
- Structs and Unions
- How memory works
- Virtual Memory

- Version Control with Git
- Inheritance and Overloading
- Generics
- Exceptions
- Lambda Expressions
- Design Patterns
- Concepts of Concurrency
- Concurrency: Object Locks
- Modern Concurrency

- System Models
- Naming and Distributed File Systems
- Synchronisation and Concurrency
- Fault Tolerance and Security
- Clusters and Grids
- Virtualisation
- Data Centers
- Mobile Computing

- Transition to Scala
- Functional Programming
- Syntax Analysis
- Name Analysis
- Type Analysis
- Transformation and Compilation
- Control Abstraction
- Implementing Data Abstraction
- Language Runtimes

- Transition to Coq
- Proof by Induction, Structured Data
- Polymorphism and Higher-Order Functions
- More Basic Tactics
- Logical Reasoning in Proof Assistants
- Inductive Propositions
- Maps
- An Imperative Programming Language
- Program Equivalence
- Hoare Logic
- Small-Step Operational Semantics
- Simply-typed Lambda Calculus

- Be able to create static processing sketches and understand how they came to be.
- Have the tools to create sketches based on your own imagination.
- Understand the categories into which values might fit and the consequences of these categories.

Chapters 1 and 2 of Learning Processing by Daniel Shiffman. Macquarie University students have access to an electronic copy via the library.

Coordinate System tutorial at processing.org.

A processing program is made up of *expressions* and *statements*. Statements come later, this topic shows us how to build up expressions to get a program.

Processing has a whole pile of built in expressions you can use, most of which cause things to occur on the screen. The full-set of expressions available are documented at the processing reference page but we will list here all the ones you need in this text. In processing, you also have a full suite of mathematical expressions available, plus (`+`

), minus (`-`

), multiply (`*`

), and divide (`/`

).

Warning!: Division might now work the way you expect. We will explain why in a later topic.

So far, we have seen many *values*:

`1`

is a value, the number one`-34`

is a value, the number -34`3.4`

is a value, the number 3.4

This might all seem terribly obvious, but it is about to become very important.

Values are grouped into *types*. A type is a set of values that all work the same. All the whole numbers work the same, so there is a type for these (`int`

). All the precise numbers work the same, so there is a type for these (`float`

). Here is a list of all the types you need to worry about:

`int`

: whole numbers. Examples are`1`

,`2`

,`-7`

,`0`

,`1023977389`

.`float`

: numbers that might have decimal parts. Examples are`1.2`

,`2.45644`

,`-13.0`

,`0.0`

.`char`

: single characters that might appear in text. Examples include`c`

,`g`

,`^`

,`$`

,`@`

,`z`

.

What type is each of the following values?

`12`

`41.0`

`0`

`0.0`

- ‘c’
- ‘f’
- ‘0’
- h

`12`

:`int`

(integer)`41.0`

:`float`

(floating point number)`0`

:`int`

(integer)`0.0`

:`float`

(floating point number)- ‘c’ :
`char`

(character) - ‘f’ :
`char`

(character) - ‘0’ :
`char`

(character) - h :
**this is an error. the processing compiler will reject values like this**

You must be careful to know what type any particular value has because it affects how the program runs. For example, each of the basic operations we know about have particular effects based on the types it is working on.

type | `+` | `-` | `*` | `/` |
---|---|---|---|---|

`int` | normal addition | normal subtraction | normal multiplication | integer division |

`float` | normal addition | normal subtraction | normal multiplication | normal division |

`char` | something strange | something strange | something strange | something strange |

You will notice that mostly things work out as you expect, but you need to be aware of *integer division* and *not doing arithmetic on characters*. Don’t ever try and do arithmetic on characters and as for integer division…

`float`

can be an `int`

…If you see the value `0`

, how do you know if Processing thinks it is an `int`

or a `float`

? Well, if you see `0`

, it will think it is an `int`

and if you see `0.0`

, processing will think it is a `float`

. However, the back-and-forth between these two options gets complex once we get into more complicated code but for now, you need to be aware that it matters what Processing thinks a value is and you can make a pretty good guess at what it thinks.

Processing will also convert between some types if you ask it to. In particular, it will very happily convert an `int`

into a `float`

. You should be able to see why this is always OK. It won’t do the opposite though because not all floats have equivalent integers.

While we are thinking about it, how does Processing know when I mean the *character* `0`

instead of the number `0`

? All characters are within inverted commas, so the character `0`

will look like `'0'`

. The same holds for all other characters, they look like `'c'`

, `'g'`

, `'^'`

, `'$'`

, `'@'`

, `'z'`

in Processing code

Write processing code that will draw a blue circle that is 20 pixels wide in the center of the sketch window. You should use pantone 2178 C as your inspiration.

1
2
3

noStroke();
fill(92, 136, 218); // These RGB values give the right shade of blue
circle(width/2, height/2, 20);

Identify the *type* of each item in the following code.

1

circle(width/2, height/2, 40);

- What is the type of
`width`

- What is the type of
`height`

- What is the type of
`2`

- What is the type of
`40`

- What is the type of
`width/2`

- What is the type of
`height/2`

`circle`

expects`floats`

according to the processing reference. How can you resolve this with your answers above.

`int`

because it is set from`size`

which only accepts`int`

s`int`

because it is set from`size`

which only accepts`int`

s`int`

because if you don’t say otherwise, processing treats numbers as integers`int`

because if you don’t say otherwise, processing treats numbers as`int`

because dividing an`int`

by another`int`

will give you a third`int`

`int`

because dividing an`int`

by another`int`

will give you a third`int`

- It is always OK to give an
`int`

where a`float`

should go, processing will automatically convert it for you.

*New content coming soon*