SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Coding Chinese
Dragons

in Processing 3
@stevebattle
steve.battle@uwe.ac.uk
This centipede style kite has a large Dragon head with a long train of disks for a tail.
Image courtesy of mosoma on flickr
Workshop goal
• The ‘Processing’
language is
about coding for
the visual arts.
In this workshop
you will learn
how to create an
animated Chinese
Dragon 'kite'.
Getting started
• Download Processing: 

http://www.processing.org
• Start Processing
• Create a new project: 

File > New
• Save the project as ‘dragon’: 

File > Save
Hello World
The output console
Your code
Click to run
Computer Graphics
The display window
Blue Sky
•Tools >
•Color selector…
Don’t type this
value…
Select a nice blue sky
colour, Copy then paste it into
your code
The Dragon’s Head
• The image for the Dragon’s head is at: 

http://stevebattle.github.io/dragon/head.gif
• Save image to “Downloads”
• Go back to Processing and select your code window.
• Sketch > Add File..
• Navigate to ‘head.gif’ in Downloads and Open.
• Confirm you have the image in your project:
• Sketch > Show Sketch Folder
Variables
Draw the head
Assign a value to
the variable
Centre the image on
the mouse
In Processing an
image is a PImage
This is the variable
declaration
The Dragon’s Body
1
2
3
4
5
0
6
7
The for loop
for (INITIALIZE; TEST; INCREMENT) {
...
}
initialise
loop variable, i
i ‘less than’ n test
increment i
expression
Relations
< less than
> greater than
<= less than or equals
>= greater than or equals
!= not equals
== equals
e.g. i < n
low precedence
high precedence
Expressions
* times
/ divide
%
modulo

(remainder)
+ add
- subtract
multiplicative
operators come first
multiplicative
operators come first
multiplicative
operators come first
additive
operators come second
additive
operators come second
e.g. mouseY-25*(n-i)
Use brackets to
override precedence
Co-ordinates
x coordinate
ycoordinate
y increases
as you move down the
window
origin
In Processing it’s
called a PVector
An x,y coordinate is
called a vector
Arrays
ERROR!
p is empty
Declare the array
Initialise the array
store mouse
vector in array
get
earlier mouse vectors
from array
if (CONDITION) …
else …
if statement
if
statement checks that
p is not empty
Slow the frame-rate
The Dragon’s Body
• The image for the Dragon’s body is at: 

http://stevebattle.github.io/dragon/body.gif
• Save image to “Downloads”
• Go back to Processing and select your code window.
• Sketch > Add File..
• Navigate to ‘body.gif’ in Downloads and Open.
• Confirm you have the image in your project:
• Sketch > Show Sketch Folder
Declare new variable
load image
display
image
Translate
Rotate
Coding Chinese Dragons

Contenu connexe

Similaire à Coding Chinese Dragons

From Elixir to Akka (and back) - ElixirConf Mx 2017
From Elixir to Akka (and back) - ElixirConf Mx 2017From Elixir to Akka (and back) - ElixirConf Mx 2017
From Elixir to Akka (and back) - ElixirConf Mx 2017Agustin Ramos
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanJimin Hsieh
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developersJim Roepcke
 
Test First Teaching
Test First TeachingTest First Teaching
Test First TeachingSarah Allen
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202Mahmoud Samir Fayed
 
React Native One Day
React Native One DayReact Native One Day
React Native One DayTroy Miles
 
The Ring programming language version 1.5.2 book - Part 6 of 181
The Ring programming language version 1.5.2 book - Part 6 of 181The Ring programming language version 1.5.2 book - Part 6 of 181
The Ring programming language version 1.5.2 book - Part 6 of 181Mahmoud Samir Fayed
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnArnaud Joly
 
Django’s nasal passage
Django’s nasal passageDjango’s nasal passage
Django’s nasal passageErik Rose
 
Comparitive Analysis of Algorithm strategies
Comparitive Analysis of Algorithm strategiesComparitive Analysis of Algorithm strategies
Comparitive Analysis of Algorithm strategiesTalha Shaikh
 
Introductiontoprogramminginscala
IntroductiontoprogramminginscalaIntroductiontoprogramminginscala
IntroductiontoprogramminginscalaAmuhinda Hungai
 
Intro to React
Intro to ReactIntro to React
Intro to ReactTroy Miles
 
Making php see, confoo 2011
Making php see, confoo 2011 Making php see, confoo 2011
Making php see, confoo 2011 Bachkoutou Toutou
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potterdistributed matters
 

Similaire à Coding Chinese Dragons (20)

From Elixir to Akka (and back) - ElixirConf Mx 2017
From Elixir to Akka (and back) - ElixirConf Mx 2017From Elixir to Akka (and back) - ElixirConf Mx 2017
From Elixir to Akka (and back) - ElixirConf Mx 2017
 
Python lecture 8
Python lecture 8Python lecture 8
Python lecture 8
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developers
 
Test First Teaching
Test First TeachingTest First Teaching
Test First Teaching
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
The Ring programming language version 1.5.2 book - Part 6 of 181
The Ring programming language version 1.5.2 book - Part 6 of 181The Ring programming language version 1.5.2 book - Part 6 of 181
The Ring programming language version 1.5.2 book - Part 6 of 181
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
 
Django’s nasal passage
Django’s nasal passageDjango’s nasal passage
Django’s nasal passage
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Java tut1
Java tut1Java tut1
Java tut1
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Comparitive Analysis of Algorithm strategies
Comparitive Analysis of Algorithm strategiesComparitive Analysis of Algorithm strategies
Comparitive Analysis of Algorithm strategies
 
Introductiontoprogramminginscala
IntroductiontoprogramminginscalaIntroductiontoprogramminginscala
Introductiontoprogramminginscala
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Making php see, confoo 2011
Making php see, confoo 2011 Making php see, confoo 2011
Making php see, confoo 2011
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potter
 

Plus de Steven Battle

Ashby's Mobile homeostat
Ashby's Mobile homeostatAshby's Mobile homeostat
Ashby's Mobile homeostatSteven Battle
 
Turtle Geometry the Python Way
Turtle Geometry the Python WayTurtle Geometry the Python Way
Turtle Geometry the Python WaySteven Battle
 
Quick & Dirty Model-Driven Architecture Evaluation
Quick & Dirty Model-Driven Architecture EvaluationQuick & Dirty Model-Driven Architecture Evaluation
Quick & Dirty Model-Driven Architecture EvaluationSteven Battle
 
Autaptic Circuits for Neural Vehicles
Autaptic Circuits for Neural VehiclesAutaptic Circuits for Neural Vehicles
Autaptic Circuits for Neural VehiclesSteven Battle
 
The Animated Android: Graphical Animation in Processing 2
The Animated Android: Graphical Animation in Processing 2The Animated Android: Graphical Animation in Processing 2
The Animated Android: Graphical Animation in Processing 2Steven Battle
 
Blitz Resurrection: Re-creating a classic 80s video game in Processing 2
Blitz Resurrection: Re-creating a classic 80s video game in Processing 2Blitz Resurrection: Re-creating a classic 80s video game in Processing 2
Blitz Resurrection: Re-creating a classic 80s video game in Processing 2Steven Battle
 
Adventures in ARM Assembler
Adventures in ARM AssemblerAdventures in ARM Assembler
Adventures in ARM AssemblerSteven Battle
 
Processing 2.0 + Open Data
Processing 2.0 + Open DataProcessing 2.0 + Open Data
Processing 2.0 + Open DataSteven Battle
 
Ecore Model Reflection in RDF
Ecore Model Reflection in RDFEcore Model Reflection in RDF
Ecore Model Reflection in RDFSteven Battle
 
Introduction to App Development with Processing 2
Introduction to App Development with Processing 2Introduction to App Development with Processing 2
Introduction to App Development with Processing 2Steven Battle
 
CycQL: A SPARQL Adapter for OpenCyc
CycQL: A SPARQL Adapter for OpenCycCycQL: A SPARQL Adapter for OpenCyc
CycQL: A SPARQL Adapter for OpenCycSteven Battle
 

Plus de Steven Battle (14)

Droid Geometry
Droid GeometryDroid Geometry
Droid Geometry
 
Squishy logic
Squishy logicSquishy logic
Squishy logic
 
Ashby's Mobile homeostat
Ashby's Mobile homeostatAshby's Mobile homeostat
Ashby's Mobile homeostat
 
Turtle Geometry the Python Way
Turtle Geometry the Python WayTurtle Geometry the Python Way
Turtle Geometry the Python Way
 
Quick & Dirty Model-Driven Architecture Evaluation
Quick & Dirty Model-Driven Architecture EvaluationQuick & Dirty Model-Driven Architecture Evaluation
Quick & Dirty Model-Driven Architecture Evaluation
 
Autaptic Circuits for Neural Vehicles
Autaptic Circuits for Neural VehiclesAutaptic Circuits for Neural Vehicles
Autaptic Circuits for Neural Vehicles
 
The Animated Android: Graphical Animation in Processing 2
The Animated Android: Graphical Animation in Processing 2The Animated Android: Graphical Animation in Processing 2
The Animated Android: Graphical Animation in Processing 2
 
Blitz Resurrection: Re-creating a classic 80s video game in Processing 2
Blitz Resurrection: Re-creating a classic 80s video game in Processing 2Blitz Resurrection: Re-creating a classic 80s video game in Processing 2
Blitz Resurrection: Re-creating a classic 80s video game in Processing 2
 
Robots Are GO!
Robots Are GO!Robots Are GO!
Robots Are GO!
 
Adventures in ARM Assembler
Adventures in ARM AssemblerAdventures in ARM Assembler
Adventures in ARM Assembler
 
Processing 2.0 + Open Data
Processing 2.0 + Open DataProcessing 2.0 + Open Data
Processing 2.0 + Open Data
 
Ecore Model Reflection in RDF
Ecore Model Reflection in RDFEcore Model Reflection in RDF
Ecore Model Reflection in RDF
 
Introduction to App Development with Processing 2
Introduction to App Development with Processing 2Introduction to App Development with Processing 2
Introduction to App Development with Processing 2
 
CycQL: A SPARQL Adapter for OpenCyc
CycQL: A SPARQL Adapter for OpenCycCycQL: A SPARQL Adapter for OpenCyc
CycQL: A SPARQL Adapter for OpenCyc
 

Dernier

Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Dernier (20)

Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Coding Chinese Dragons

  • 1. Coding Chinese Dragons
 in Processing 3 @stevebattle steve.battle@uwe.ac.uk
  • 2. This centipede style kite has a large Dragon head with a long train of disks for a tail. Image courtesy of mosoma on flickr
  • 3. Workshop goal • The ‘Processing’ language is about coding for the visual arts. In this workshop you will learn how to create an animated Chinese Dragon 'kite'.
  • 4. Getting started • Download Processing: 
 http://www.processing.org • Start Processing • Create a new project: 
 File > New • Save the project as ‘dragon’: 
 File > Save
  • 5. Hello World The output console Your code Click to run
  • 7. Blue Sky •Tools > •Color selector… Don’t type this value… Select a nice blue sky colour, Copy then paste it into your code
  • 8. The Dragon’s Head • The image for the Dragon’s head is at: 
 http://stevebattle.github.io/dragon/head.gif • Save image to “Downloads” • Go back to Processing and select your code window. • Sketch > Add File.. • Navigate to ‘head.gif’ in Downloads and Open. • Confirm you have the image in your project: • Sketch > Show Sketch Folder
  • 9. Variables Draw the head Assign a value to the variable Centre the image on the mouse In Processing an image is a PImage This is the variable declaration
  • 11. The for loop for (INITIALIZE; TEST; INCREMENT) { ... } initialise loop variable, i i ‘less than’ n test increment i expression
  • 12. Relations < less than > greater than <= less than or equals >= greater than or equals != not equals == equals e.g. i < n
  • 13. low precedence high precedence Expressions * times / divide % modulo
 (remainder) + add - subtract multiplicative operators come first multiplicative operators come first multiplicative operators come first additive operators come second additive operators come second e.g. mouseY-25*(n-i) Use brackets to override precedence
  • 14. Co-ordinates x coordinate ycoordinate y increases as you move down the window origin In Processing it’s called a PVector An x,y coordinate is called a vector
  • 15. Arrays ERROR! p is empty Declare the array Initialise the array store mouse vector in array get earlier mouse vectors from array
  • 16. if (CONDITION) … else … if statement if statement checks that p is not empty Slow the frame-rate
  • 17. The Dragon’s Body • The image for the Dragon’s body is at: 
 http://stevebattle.github.io/dragon/body.gif • Save image to “Downloads” • Go back to Processing and select your code window. • Sketch > Add File.. • Navigate to ‘body.gif’ in Downloads and Open. • Confirm you have the image in your project: • Sketch > Show Sketch Folder
  • 18. Declare new variable load image display image