Learning Processing: Difference between revisions
(Created page with "These informations will be added into categories in a close future<br> ===Basic learnings=== <br> '''void setup''' define parameters in the first place/beginning that will re...") |
No edit summary |
||
Line 138: | Line 138: | ||
3rd step: use the variable <br> | 3rd step: use the variable <br> | ||
<syntaxhighlight lang="processing"> | |||
int circleX; | |||
void setup() { | |||
size(540, 960); | |||
circleX = 100; | |||
} | |||
void draw() { | |||
background(#EAE8E8); | |||
fill(#000000); | |||
ellipse(circleX,180,24,24); | |||
//pmouse allows to draw to previsou to current point | |||
} | |||
</syntaxhighlight> | |||
4th step: evaluate a new value to CircleX by incrementing it. Then it gonna move! <br> | |||
<syntaxhighlight lang="processing"> | |||
int circleX; | |||
void setup() { | |||
size(540, 960); | |||
circleX = 100; | |||
} | |||
void draw() { | |||
//Drawing | |||
background(#EAE8E8); | |||
fill(#000000); | |||
ellipse(circleX,180,24,24); | |||
//Else | |||
circleX = circleX + 1; | |||
} | |||
</syntaxhighlight> |
Revision as of 18:18, 1 October 2020
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
int circleX;
void setup() {
size(540, 960);
circleX = 100;
}
void draw() {
background(#EAE8E8);
fill(#000000);
ellipse(circleX,180,24,24);
//pmouse allows to draw to previsou to current point
}
4th step: evaluate a new value to CircleX by incrementing it. Then it gonna move!
int circleX;
void setup() {
size(540, 960);
circleX = 100;
}
void draw() {
//Drawing
background(#EAE8E8);
fill(#000000);
ellipse(circleX,180,24,24);
//Else
circleX = circleX + 1;
}