SlideShare una empresa de Scribd logo
1 de 13
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?

Más contenido relacionado

La actualidad más candente

La actualidad más candente (13)

Python programming lab3 250215
Python programming lab3 250215Python programming lab3 250215
Python programming lab3 250215
 
Sequence Types in Python Programming
Sequence Types in Python ProgrammingSequence Types in Python Programming
Sequence Types in Python Programming
 
Sqlalchemy lightning talk
Sqlalchemy lightning talkSqlalchemy lightning talk
Sqlalchemy lightning talk
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Functional programming with haskell
Functional programming with haskellFunctional programming with haskell
Functional programming with haskell
 
Functional Core and Imperative Shell - Game of Life Example - Haskell and Scala
Functional Core and Imperative Shell - Game of Life Example - Haskell and ScalaFunctional Core and Imperative Shell - Game of Life Example - Haskell and Scala
Functional Core and Imperative Shell - Game of Life Example - Haskell and Scala
 
Introduction to haskell
Introduction to haskellIntroduction to haskell
Introduction to haskell
 
Tutorial matlab
Tutorial matlabTutorial matlab
Tutorial matlab
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
 
[1062BPY12001] Data analysis with R / week 3
[1062BPY12001] Data analysis with R / week 3[1062BPY12001] Data analysis with R / week 3
[1062BPY12001] Data analysis with R / week 3
 
Sql
SqlSql
Sql
 
The Ring programming language version 1.5.2 book - Part 18 of 181
The Ring programming language version 1.5.2 book - Part 18 of 181The Ring programming language version 1.5.2 book - Part 18 of 181
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
The Ring programming language version 1.2 book - Part 12 of 84The Ring programming language version 1.2 book - Part 12 of 84
The Ring programming language version 1.2 book - Part 12 of 84
 

Destacado

Mb5 858-q&a-demo-cert magic
Mb5 858-q&a-demo-cert magicMb5 858-q&a-demo-cert magic
Mb5 858-q&a-demo-cert magic
nikol
 
Mobile Workflow and the Showroom Process of the Near Future
Mobile Workflow and the Showroom Process of the Near FutureMobile Workflow and the Showroom Process of the Near Future
Mobile Workflow and the Showroom Process of the Near Future
Jeff Kershner
 

Destacado (13)

From desires, obligations and norms to goals
From desires, obligations and norms to goalsFrom desires, obligations and norms to goals
From desires, obligations and norms to goals
 
Mb5 858-q&a-demo-cert magic
Mb5 858-q&a-demo-cert magicMb5 858-q&a-demo-cert magic
Mb5 858-q&a-demo-cert magic
 
Milan Mobile Games
Milan Mobile GamesMilan Mobile Games
Milan Mobile Games
 
Kijken naar het glas
Kijken naar het glasKijken naar het glas
Kijken naar het glas
 
Secrets of the Inbox - Presentation for Driving Sales Summit - #dses
Secrets of the Inbox - Presentation for Driving Sales Summit - #dsesSecrets of the Inbox - Presentation for Driving Sales Summit - #dses
Secrets of the Inbox - Presentation for Driving Sales Summit - #dses
 
Leadership lessons-from-obama-
Leadership lessons-from-obama-Leadership lessons-from-obama-
Leadership lessons-from-obama-
 
The purpose of life & universe ( iln )
The purpose of  life & universe  ( iln )The purpose of  life & universe  ( iln )
The purpose of life & universe ( iln )
 
Mind tree story
Mind tree storyMind tree story
Mind tree story
 
XBee and RFID
XBee and RFIDXBee and RFID
XBee and RFID
 
Mobile Workflow and the Showroom Process of the Near Future
Mobile Workflow and the Showroom Process of the Near FutureMobile Workflow and the Showroom Process of the Near Future
Mobile Workflow and the Showroom Process of the Near Future
 
Mobile Path to Purchase 2014 - New Shopper Mindset
Mobile Path to Purchase 2014 - New Shopper MindsetMobile Path to Purchase 2014 - New Shopper Mindset
Mobile Path to Purchase 2014 - New Shopper Mindset
 
HookLogic / AutoHook Suite - Building the Ultimate Attribution Model in Autom...
HookLogic / AutoHook Suite - Building the Ultimate Attribution Model in Autom...HookLogic / AutoHook Suite - Building the Ultimate Attribution Model in Autom...
HookLogic / AutoHook Suite - Building the Ultimate Attribution Model in Autom...
 
Winning The Customer With a Great Experience
Winning The Customer With a Great ExperienceWinning The Customer With a Great Experience
Winning The Customer With a Great Experience
 

Similar a Programming for Artists and Designers: Week 3

Mdx Basics
Mdx BasicsMdx Basics
Mdx Basics
ALIPPHAR
 
Oracle sql functions
Oracle sql functionsOracle sql functions
Oracle sql functions
Vivek Singh
 
Notes5
Notes5Notes5
Notes5
hccit
 
Lab Session for sql programming language 1.pptx
Lab Session for sql programming language 1.pptxLab Session for sql programming language 1.pptx
Lab Session for sql programming language 1.pptx
meharikiros2
 
Real World Haskell: Lecture 6
Real World Haskell: Lecture 6Real World Haskell: Lecture 6
Real World Haskell: Lecture 6
Bryan O'Sullivan
 
Notes2
Notes2Notes2
Notes2
hccit
 
How to start functional programming (in Scala): Day1
How to start functional programming (in Scala): Day1How to start functional programming (in Scala): Day1
How to start functional programming (in Scala): Day1
Taisuke Oe
 
Please make the complete program, Distinguish between header files a.pdf
Please make the complete program, Distinguish between header files a.pdfPlease make the complete program, Distinguish between header files a.pdf
Please make the complete program, Distinguish between header files a.pdf
SALES97
 
Excel Useful Tips
Excel Useful TipsExcel Useful Tips
Excel Useful Tips
Parul_100in
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
priestmanmable
 

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

Mdx Basics
Mdx BasicsMdx Basics
Mdx Basics
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptx
 
Cocoa Design Patterns in Swift
Cocoa Design Patterns in SwiftCocoa Design Patterns in Swift
Cocoa Design Patterns in Swift
 
Oracle sql functions
Oracle sql functionsOracle sql functions
Oracle sql functions
 
Notes5
Notes5Notes5
Notes5
 
Functional programming and Elm
Functional programming and ElmFunctional programming and Elm
Functional programming and Elm
 
Principles of functional progrmming in scala
Principles of functional progrmming in scalaPrinciples of functional progrmming in scala
Principles of functional progrmming in scala
 
Living in the ES6 Future, Today
Living in the ES6 Future, TodayLiving in the ES6 Future, Today
Living in the ES6 Future, Today
 
Lab Session for sql programming language 1.pptx
Lab Session for sql programming language 1.pptxLab Session for sql programming language 1.pptx
Lab Session for sql programming language 1.pptx
 
7 Habits For a More Functional Swift
7 Habits For a More Functional Swift7 Habits For a More Functional Swift
7 Habits For a More Functional Swift
 
Ms excel
Ms excelMs excel
Ms excel
 
Real World Haskell: Lecture 6
Real World Haskell: Lecture 6Real World Haskell: Lecture 6
Real World Haskell: Lecture 6
 
Getting functional with elixir
Getting functional with elixirGetting functional with elixir
Getting functional with elixir
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-C
 
Notes2
Notes2Notes2
Notes2
 
How to start functional programming (in Scala): Day1
How to start functional programming (in Scala): Day1How to start functional programming (in Scala): Day1
How to start functional programming (in Scala): Day1
 
Please make the complete program, Distinguish between header files a.pdf
Please make the complete program, Distinguish between header files a.pdfPlease make the complete program, Distinguish between header files a.pdf
Please make the complete program, Distinguish between header files a.pdf
 
Excel Useful Tips
Excel Useful TipsExcel Useful Tips
Excel Useful Tips
 
Lecture 02 visualization and programming
Lecture 02   visualization and programmingLecture 02   visualization and programming
Lecture 02 visualization and programming
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

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?