ICM: HW week 4

Revised Sketch Code:

Full screen

Editor screen

 

Original Sketch Code

Full screen

Editor screen

Assignment

Re-work an existing assignment, using functions to compartmentalize your code. Write at least one function that takes parameters and one function that has a return value. If your existing assignments already make use of functions, or if you don’t want to build on existing work, feel free to make a new experiment from scratch. Goals and things to try:

  • Break code out of setup() and draw() into functions.
  • Use a function to draw a complex design (like this) multiple times with different arguments.
  • Write a function to that returns the result of a mathematical operation that you need to do several times in your code.
  • Reorganize “groups of variables” into objects.
  • If you are feeling ambitious, try embedding a function into an object.

 

Screen Shot 2018-10-04 at 8.11.41 AM

For this week’s assignment I decided to try to rework my Persian rug closeup sketch. I was able to create a couple functions that would duplicate patterns for me like the ones below:

** after re-visiting shiffman’s 5.1-5.3 videos, I realize I should to comb back through not only for for loops  but also to write my functions to  take parameters instead of using translate **

 

 

Screen Shot 2018-10-04 at 8.20.55 AM.png

// BOTTOM LAYER COLOR BLOCKS
//orange
push();
noStroke();
fill(196, 70, 0);
translate(300, 0);
foundationStripes();
pop();
//lightTan
push();
noStroke();
fill(239, 242, 205);
translate(-205, 0);
noStroke();
fill(239, 242, 205);
foundationStripes();
pop();
//skyBlue
push();
noStroke();
fill(167, 207, 209);
translate(-300, 0);
foundationStripes();
pop();
//brickRed
push();
fill(130, 82, 70);
noStroke();
translate(-410, 0);
foundationStripes();
pop();
//greenTan
push();
noStroke();
fill(203, 200, 179);
translate(-430, 0);
foundationStripes();
pop();
//navyBlue
push();
noStroke();
fill(53, 69, 94);
translate(-522, 0);
foundationStripes();
pop();

Screen Shot 2018-10-04 at 8.21.32 AM.png

 

 

 

 

 

Screen Shot 2018-10-04 at 8.31.07 AM.png

 

//  BLUE CIRCLE COLUMN
// Row 1
push();
translate(-50, 0);
makeCircleColumn();
pop();
// Row 2
makeCircleColumn();
}
Screen Shot 2018-10-04 at 8.32.59 AM.png

 

 

 

 

Screen Shot 2018-10-04 at 8.38.14 AM.png
// Blue Triangle
push();
fill(53, 69, 94);
translate(-30, 0);
scale(1.2);
triangleParty();
pop();
// Small Green Triangle
push();
translate(70, 20);
fill(141, 160, 89);
scale(1.2);
triangleParty();
pop();
// Large Green Triangle
push();
translate(-200, -285);
fill(141, 160, 89);
scale(4.0);
triangleParty();
pop();

Screen Shot 2018-10-04 at 8.11.41 AM.png

 

 

I  would like to comb back through and translate the repetitive lines of code into For loops ❤  (example: all the circle lines) I also used Scale but would like to play with a Return Value in a function too. Thinking about:

  1. Modularity 
  2. Reusability 
  3. Return Values

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s