Here is what you need to type in and some comments explaining what they are.
// will comment out a single line of code
/* will comment out a whole paragraph of code*/
-----------------------------------------------
This is a red background with white line that you control and pull with mouse.
void setup() {
// comment: this stuff only runs one time
size(200, 200); // the size of the applet
smooth(); // make it anti-aliased
background(255, 0, 0); // make the background red color
stroke(255); // set the fill color to white
}
void draw() {
// this is stuff you want to loop all the time
background(255, 0, 0);
// make the background red color - what if I take this out?
line(0,0,mouseX,mouseY);
}
---------------------------
Variables
-
mouseX and mouseY are a sort of a variable....
- You can make line art, word art, shape art
.
-----------------------------
This is a white square that starts in the upper left corner and moves diagonally to the bottom right corner; as it travels it leaves a black trail. Does not repeat.
int myint = 0 ;
void setup() {
size (400,400) ;}
void draw() {
rect(myint,myint,50,50);
myint = myint + 1;}
------------------------------
This is a black line that starts in the upper left corner and moves diagonally to the bottom right corner; If you move the mouse onto the line a white square will form and reshape itself as you move the mouse around. As it travels it leaves a black trail. Does not repeat.
int myint = 0 ;
void setup() {
size (400,400) ;
}
void draw() {
rect(myint,myint,mouseX,mouseY);
myint = myint + 1;
}
---------------------------
This has a black background in the middle at the top, a white square drops down to the bottom of the page and disappears again. Does not repeat.
int myint = 0 ;
void setup() {
size (400,400) ; }
void draw() {
background(0,0,0);
rect(100,myint,50,50);
myint = myint + 2;
println(myint); }
-------------------------------------
This is a white square that starts in the upper left corner and moves diagonally to the bottom right corner; as it travels it leaves a black trail. It moves to Seconds and after a minute it repeats.
//time process: clock
void setup() {
size (200,200) ; }
void draw() {
rect(second(), second(), 20,20);
}
----------------------------