For the complete documentation index, see llms.txt. This page is also available as Markdown.

Week 05

Functions: the basics

We have used functions before......

1. Function we are calling 'ellipse function" to make ellipse..

ellipse(100,100,100,100); 

But we did not make/define this function as "ellipse(x, y, width, height){ .... .... ...}"

We are just using the function!!

2. Function setup started functioning when the page opens without calling it...

But we made/defined it.

function setup() {
  createCanvas(500, 500);  
}

Both are functions but it was either 'Defined Previously' OR 'Functioning before Calling it.'

These are library functions. It is done by P5js library. For example, tone.js is a musical library which has functions already defined by the developer, Yotam Mann

https://tonejs.github.io/

Function needs "Define" and "Call"

function setup()

We defined setup:

But we did not call:

ellipse()

These are library functions... we are using p5.js library.

Let's 'Define' and 'Call' Your Own Function.

  1. Modular

  2. Reusable

We made ball bouncing with ball object.

https://editor.p5js.org/kdoodoo/sketches/SJyXQ_g5m

Here we have 3 functions:

  1. Drawing

  2. Bouncing

  3. Moving

Let's make with functions.

function move

function bounce

function display

https://editor.p5js.org/kdoodoo/sketches/ByW1H_x9X

Define and Call

Define

Call

Assignment

Make a project with your own function.

https://goo.gl/forms/FslZlLy46wAns0HI3

Schedule for Next Week Thursday OR Friday

보강 시간 입력 바랍니다. 다음 주 목/금 중 가능시간

https://goo.gl/forms/WFa0kI75GirvCU8B3

Last updated