SlideShare a Scribd company logo
Week 2: Functions
Runs once Runs over and over Runs each  time you click the mouse A Brief Detour: Mouse and Key Presses
Runs once Runs over and over A Brief Detour: Mouse and Key Presses Try replacing  mousePressed () with: keyPressed () mouseReleased () mouseDragged () How are these different?
Functions (you should know what this does)
Functions This does the same thing… but with more lines! Why do I care?
Anatomy of a Function (similar words: method, subroutine) void  renderCircle(){ fill (200); ellipse (x,y,100,100); } what’s this? what’s this? function code function name
Do the same thing in slightly different ways Both circles look the same, but behave differently Functions: Why do I care?
If you change the function code, you change how the circles look without changing their behavior Functions: Why do I care? make a different shape here
Sometimes it’s just neater and easier to read Functions: Why do I care? Blahblahblah make 6 ellipses in three alternating colors and enclose them in a rectangle  that has a randomly changing color and put a line through it all…
Anatomy of a Function what’s this? parameters (TYPE and NAME) function code function name void  renderCircle( int  _x,  int  _y){ fill (200); ellipse (_x,_y,100,100); }
You can use a function to ask a question and receive an answer Functions: Why do I care?
boolean  inCircle( int  _x,  int  _y){ if ( sq (_x-x) +  sq (_y-y) <  sq (50))  return   true ; else   return   false ; } Anatomy of a Function data return type parameters (TYPE and NAME) function code function name
YOU CAN USE OTHER PEOPLE’S FUNCTIONS Functions: Why do I care?

More Related Content

PDF
iRODS Rule Language Cheat Sheet
PDF
SQL Functions and Operators
PDF
Day 2b i/o.pptx
PDF
Day 1b R structures objects.pptx
PDF
Day 2 repeats.pptx
PDF
Day 1d R structures & objects: matrices and data frames.pptx
PDF
Python Usage (5-minute-summary)
PDF
python- Variables and data types
iRODS Rule Language Cheat Sheet
SQL Functions and Operators
Day 2b i/o.pptx
Day 1b R structures objects.pptx
Day 2 repeats.pptx
Day 1d R structures & objects: matrices and data frames.pptx
Python Usage (5-minute-summary)
python- Variables and data types

What's hot (13)

PPTX
Python programming lab3 250215
PPTX
Sequence Types in Python Programming
PDF
Sqlalchemy lightning talk
PDF
Introduction to python programming
PDF
Functional programming with haskell
PDF
Functional Core and Imperative Shell - Game of Life Example - Haskell and Scala
PDF
Introduction to haskell
PDF
Tutorial matlab
PDF
Monoids - Part 1 - with examples using Scalaz and Cats
PDF
[1062BPY12001] Data analysis with R / week 3
PDF
The Ring programming language version 1.5.2 book - Part 18 of 181
PDF
The Ring programming language version 1.2 book - Part 12 of 84
Python programming lab3 250215
Sequence Types in Python Programming
Sqlalchemy lightning talk
Introduction to python programming
Functional programming with haskell
Functional Core and Imperative Shell - Game of Life Example - Haskell and Scala
Introduction to haskell
Tutorial matlab
Monoids - Part 1 - with examples using Scalaz and Cats
[1062BPY12001] Data analysis with R / week 3
The Ring programming language version 1.5.2 book - Part 18 of 181
The Ring programming language version 1.2 book - Part 12 of 84
Ad

Similar to Programming for Artists and Designers: Week 3 (20)

DOC
Mdx Basics
PPTX
Using-Python-Libraries.9485146.powerpoint.pptx
PDF
Cocoa Design Patterns in Swift
PDF
Oracle sql functions
PDF
Notes5
PDF
Functional programming and Elm
PPTX
Principles of functional progrmming in scala
PDF
Living in the ES6 Future, Today
PPTX
Lab Session for sql programming language 1.pptx
PDF
7 Habits For a More Functional Swift
PDF
Real World Haskell: Lecture 6
PPTX
Getting functional with elixir
PDF
Swift, functional programming, and the future of Objective-C
PDF
Notes2
PDF
How to start functional programming (in Scala): Day1
PDF
Please make the complete program, Distinguish between header files a.pdf
PPT
Excel Useful Tips
PDF
Lecture 02 visualization and programming
DOCX
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
Mdx Basics
Using-Python-Libraries.9485146.powerpoint.pptx
Cocoa Design Patterns in Swift
Oracle sql functions
Notes5
Functional programming and Elm
Principles of functional progrmming in scala
Living in the ES6 Future, Today
Lab Session for sql programming language 1.pptx
7 Habits For a More Functional Swift
Real World Haskell: Lecture 6
Getting functional with elixir
Swift, functional programming, and the future of Objective-C
Notes2
How to start functional programming (in Scala): Day1
Please make the complete program, Distinguish between header files a.pdf
Excel Useful Tips
Lecture 02 visualization and programming
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
Ad

More from Tinker London (9)

PPT
Homesense @ La Cantine
PDF
Arduino Power
PPT
XBee and RFID
PPT
Programming for Artists and Designers: Week 2
PDF
Programming for Artists and Designers: Week 1
PPT
Playful
PPT
Mobile Games and Hardware Hacking
PPT
Arduino and Open Hardware
PDF
Ethernet Shield
Homesense @ La Cantine
Arduino Power
XBee and RFID
Programming for Artists and Designers: Week 2
Programming for Artists and Designers: Week 1
Playful
Mobile Games and Hardware Hacking
Arduino and Open Hardware
Ethernet Shield

Programming for Artists and Designers: Week 3

  • 2. Runs once Runs over and over Runs each time you click the mouse A Brief Detour: Mouse and Key Presses
  • 3. Runs once Runs over and over A Brief Detour: Mouse and Key Presses Try replacing mousePressed () with: keyPressed () mouseReleased () mouseDragged () How are these different?
  • 4. Functions (you should know what this does)
  • 5. Functions This does the same thing… but with more lines! Why do I care?
  • 6. Anatomy of a Function (similar words: method, subroutine) void renderCircle(){ fill (200); ellipse (x,y,100,100); } what’s this? what’s this? function code function name
  • 7. Do the same thing in slightly different ways Both circles look the same, but behave differently Functions: Why do I care?
  • 8. If you change the function code, you change how the circles look without changing their behavior Functions: Why do I care? make a different shape here
  • 9. Sometimes it’s just neater and easier to read Functions: Why do I care? Blahblahblah make 6 ellipses in three alternating colors and enclose them in a rectangle that has a randomly changing color and put a line through it all…
  • 10. Anatomy of a Function what’s this? parameters (TYPE and NAME) function code function name void renderCircle( int _x, int _y){ fill (200); ellipse (_x,_y,100,100); }
  • 11. You can use a function to ask a question and receive an answer Functions: Why do I care?
  • 12. boolean inCircle( int _x, int _y){ if ( sq (_x-x) + sq (_y-y) < sq (50)) return true ; else return false ; } Anatomy of a Function data return type parameters (TYPE and NAME) function code function name
  • 13. YOU CAN USE OTHER PEOPLE’S FUNCTIONS Functions: Why do I care?