ICM Week 5: Functions

This week we focused on creating our own functions within our  sketches. 

The first challenge was to modify the function within Exclamator so that it returns the text plus n exclamation marks.  I was able to do that by creating a new function called repeatStringNumTimes( string, n).  Check out the code here.   On line 10, you will want to edit the second argument within the function exclamate() in order to add as many exclamation points to the string as you desire. 

For our sketch this week, we were asked to refactor the code within a previous sketch by creating functions and objects, if possible.   I decided to refactor a sketch from Week 2.   The original code is here.   Within the new code, you are able to call the function moveTriangle() and fadeBackground() within the draw() function.  The parameters for moveTriangle(a, b, c) corresponds to the corners of the triangle.  by changing the arguments, you are able to speed up or slow down how quickly each particular corner moves through the space.  Within the function fadeBackground(), you are able to adjust the speed which the background fades out. 

 

Leave a Reply

Your email address will not be published. Required fields are marked *