Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

deutsche DE Version

A variable is a placeholder for a value. Variables need to be defined with a data-type, to define its storage space requirements. The name of the variable must start with a letter, but it may contain numbers within the name. In processing, variable names are case-sensitive.

...

Code Block
int length1 = 150;
int length2 = 200;
 
size(300,300); // define window size 
background(0); // define background colour
stroke(255,255,255); // define line colour
 
line(100,10,100,length1); // draw a line 
line(150,10,150,length2);
line(200,10,200,250);
 
fill(0,0,0); // fill colour
strokeWeight(5); // line thickness 
ellipse(100,length1,50,50); // draw an ellipse
ellipse(150,length2,50,50); // draw an ellipse
noFill(); // turn off fill
ellipse(200,250,50,50); // draw an ellipse


Primitive Data Types and Memory

Each kind of variable (it's data type) has an allocated amount of memory, which is enough to store a particular range of values. 

TypeBytesValue range
byte1 byte-128 to 127
short2 byte-32,768 to 32,767
int4 byte-2^31 to 2^31-1
long8 byte-2^63 to 2^63-1
float4 byte-3.4e38 to 3.4e38
double8 byte-1.7e308 to 1.7e308
boolean1 bit true or false
char2 byte

'\u0000' to '\uffff'


Operators 

An operator is a symbol that tells the computer to perform a particular math or logic operation. Some of the most common operators are:

...