Posted: Tue Sep 15
Due: Wednesday 9/15 10:00am
Submission name: w03_logo
Make a Logo Function
- Recreate your drawing from Work 02, but turn it into a function.
- “How?” you say? Follow the example below. Tomorrow we will go over what is actually happening.
- You’ll notice submission name at the top of this assignment. From now on, you should save all your programs using that name, exactly. For example, today’s work should be saved as
w03_logo.
Setup Your Main Work Repository
This can only be done after I have told you that I’ve created the repositories, I will do this during class
- Check your GitHub notifications (top-right area next to your gh avatar image) for an invitation to a new repository. The repository will be named
PD-GH_USERNAME-work(e.g.08-stuydw-work).- If you don’t see a notification, check your email.
- If you don’t see an email, attempt to visit the repository in your browser, the link will be
https://github.com/apcs-dw/REPO_NAME. replaceREPO_NAMEwith your repository name.
- Upload your processing program to the repository.
- For the moment, do so by selecting Upload files under the Add file button. You can then drag & drop your program in.
- Processing programs are saved as folders, upload the entire folder.
- If you modify your code at home, you can upload just the
w03_logo.pdefile inside the folder. GitHub will overwrite the old file.
Making & Using a Function
This is a general template you can use for this assignment. Replace the comments with your specific code.
void setup() {
size(500, 500);
//CALL YOUR FUNCTION HERE
}
void drawLogo(int x, int y) {
//YOUR DRAWING CODE HERE
//You do not need to declare x and y
//since they are in the function header.
}
As an example, if your logo code looked like this:
int x, y, logoSize;
x = 250;
y = 250;
logoSize = 100;
fill(255, 0, 0);
circle(x, y, logoSize);
fill(255);
circle(x, y, logoSize * 0.66);
fill(255, 0, 0);
circle(x, y, logoSize * 0.33);
The function version would look like this:
void setup() {
size(500, 500);
drawLogo(250, 250, 100);
}//end setup
void drawLogo(int x, int y, int logoSize) {
fill(255, 0, 0);
circle(x, y, logoSize);
fill(255);
circle(x, y, logoSize * 0.66);
fill(255, 0, 0);
circle(x, y, logoSize * 0.33);
}//drawLogo