Learning Processing
These informations will be added into categories in a close future
Basic learnings
void setup define parameters in the first place/beginning that will remain FOREVER
void setup() {}
void draw define what gonna happen and be looped infinitly
void draw() {}
void mousePressed allows to add one more conditional
void mousePressed() {}
arc() / circle() / ellipse() / line() / point() / quad() / rect() / square() / triangle() are some of the possible 2D elements you can begin with
rect(100, 1000, 100, 50);
// x, y, width, height
//x/y stands for the location of the top left of the rectange
size defines the size of the canvas
size(540, 960);
//canvas/format
mouseX or/and mouseY variable allows the shape to be redrawed endlessly
rect(mouseX, mouseY, 100, 50);
pmouseX or/and pmouseY allows to draw from previous to current point
line(pmouseX,pmouseY,mouseX,mouseY);
Make a drawing machine
Version 01
With the few elements presented just over and using line(pmouseX,pmouseY,mouseX,mouseY) it remains already quiet easy to make a very simple drawing machine.
void setup() {
size(540, 960);
background(#EAE8E8);
}
void draw() {
fill(#000000);
stroke(#000000);
line(pmouseX,pmouseY,mouseX,mouseY);
}
Version 02
Use pmouseX,pmouseY,mouseX,mouseY to allow to clean the canvas each time you click the mouse again.
void setup() {
size(540, 960);
background(#EAE8E8);
}
void draw() {
fill(#000000);
stroke(#000000);
line(pmouseX,pmouseY,mouseX,mouseY);
}
void mousePressed() {
background(#EAE8E8);
}
Make a bouncing ball
Use circleX to make up our own variable.
1st step: declare a variable
type name;
int _____;
int circleX;
2nd step: Initialize a variable by assigning a value to it
int circleX;
void setup() {
size(540, 960);
circleX = 100;
}
3rd step: use the variable