Projects are normally stored in your
sketchbook directory
which is inside your home directory.
The SparkFun Guide suggests opening preferences (File >> Preferences...)
and increasing your maximum available memory.
I don’t see any harm in this, but I've never done it before.
Also remember,
setup()
runs once at startup and
draw()
runs about 10 times a second.
Comments
It’s a good idea to use comments in your program.
You should alway include your name at the begining of your
program.
Here are two forms of comments for this.
// Marvelous assignment for CSCI 181
// John Doe, 2020
/*
Marvelous assignment for CSCI 181
John Doe, 2020
*/
Variables
All variables have a type.
The type determine the values a variable can hold.
int mySalary ;
// mySalary can hold an integer from -2147483648 to 2147483647
Note the camelcase.
It’s the thing we all must do.
Variables outside a function are global.
Variables inside a function are local.
int aUsedByBothSetupAndDraw ;
void setup() {
int xUsedOnlyByDraw ;
}
void draw() {
int yUsedOnlyByDraw ;
}
If an int value isn’t assigned a value,
its initial value is 0.
Also, void means that nothing is returned by the function.
We’ll get back to this.
Statements
The statement preforms an action, generally an assignment.
The simple statement is terminated by a semi-colon.
But statements can be be composed of bunches of statements.
Look at
some official Java documentation, for a mind expanding or
mind numbing explation
of the if statement.
Style
Take some time to look at
Ben Fry’s
style guidelines for Processing programs. Today, programmers take
style guidlines seriously.
Variables
Check out the
Processing
variables page.
Yes, you can write a program without setup
and draw. But not if you want more than
a picture.
Activity for today
Write two Processing programs, one for each of the screenshots
shown below.
The window was 500×500 and all the points are divisible by 100.
A call to strokeWeight(5) was used to
make the line visible.
You can write this one without setup
and draw.
One more thing
Upload the work you have done on this Processing program to
today’s daily moodle.
Almost any effort gets a 100%.