Programming for Artists and Designers: Week 3

349
-1

Published on

whiteboard-replacing slides for an introductory Processing course at the V&A. This week: functions

Published in: Technology, Health & Medicine
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
349
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Programming for Artists and Designers: Week 3

  1. 1. Week 2: Functions
  2. 2. Runs once Runs over and over Runs each time you click the mouse A Brief Detour: Mouse and Key Presses
  3. 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. 4. Functions (you should know what this does)
  5. 5. Functions This does the same thing… but with more lines! Why do I care?
  6. 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. 7. Do the same thing in slightly different ways Both circles look the same, but behave differently Functions: Why do I care?
  8. 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. 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. 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. 11. You can use a function to ask a question and receive an answer Functions: Why do I care?
  12. 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. 13. YOU CAN USE OTHER PEOPLE’S FUNCTIONS Functions: Why do I care?

×