Demo entry 6344621

Variables in Processing

   

Submitted by Greg on Jan 17, 2017 at 16:45
Language: Java. Code size: 619 Bytes.

/*

VARIABLES

This sketch demonstrates the use of variables in
Processing.

*/


// Initialization
int x = 25;
line(x, 10, x, 90);

// Assignment
x = 30;
line(x, 10, x, 90);

// Math: + - * / % ()
x = 25 * 2 + 3 * (4 % 3);
line(x, 10, x, 90);

// Multiple variables
int y = 70;
line(10, y, 90, y);

y = x - 10;
line(10, y, 90, y);

// Increment and decrement
y = y - 10;
line(10, y, 90, y);

y -= 10;
line(10, y, 90, y);

y++;
line(10, y, 90, y);

y += 45;
line(10, y, 90, y);

y--;
line(10, y, 90, y);


// Floating point
float q = 20.5;
line(q, q * 2, q * 3, q * 4);

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).