How can I utilize functions written by other people?
So you’ve written a function - what now?
Writing functions are not just helpful for you to be able to use your code many times, but you can also share your functions and they can be used by other people! As long as your function is defined in someone else’s code, they can call your function and use it to create their own custom art.
To that end, you will be creating a new design and turning it into a function. You will then share the design with your class on a platform chosen by your teacher. You will choose several of your classmate’s functions to use in a project to create your own unique art!
Your project should have and do the following:
Include at least three other function definitions written by your peers
Call each of the functions written by your peers at least once
Include some sort of interactivity using a conditional statement
Include one for loop that draws a function repeatedly
Explain how the sharing of functions can be useful in a development community. Beyond just art, how could this be helpful?
Time to get organized - ask your teacher how to create a separate functions.js file and link it through your HTML to keep your code neat and readable.
Create a second function and see if you can call other functions inside of that function
Include conditionals in your custom function to control your design - have different designs display when different actions are completed
NOTE: LINKING SEPARATE JS FILES
Create a separate functions.js file
In your index.html, add a line above <script src="sketch.js"></script> that says <script src="functions.js"></script>
You should be linked! Test by using a function from functions.js in your sketch and see if it works!