🗃️

🗃 U5LA1 Mini Project: Custom Function Library

How can I utilize functions written by other people?

Prompt

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

Writing Prompt:

Explain how the sharing of functions can be useful in a development community. Beyond just art, how could this be helpful?

Extensions

  • 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
There are a few ways to go about getting multiple javascript files to talk to each other in one project. The easiest way with what students know right now is to do the following:
  1. 1.
    Create a separate functions.js file
  2. 2.
    In your index.html, add a line above <script src="sketch.js"></script> that says <script src="functions.js"></script>
  3. 3.
    You should be linked! Test by using a function from functions.js in your sketch and see if it works!