G RAPHICS & I NTERACTIVE P ROGRAMMING Lecture 1 Introduction to Processing.

Slides:



Advertisements
Similar presentations
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Advertisements

1What is the Stage. 2How do you open a panel in Flash
Introduction to Programming
Game with US Beginner Tutorial. Welcome!! Who I am What is Processing? Basic Coding Input Methods Images Classes Arrays.
A Quick Introduction to Processing
Processing Lecture. 1 What is processing?
 Variables  What are they?  Declaring and initializing variables  Common uses for variables  Variables you get “for free” in Processing ▪ Aka: Built-in.
Data: Programming Design and Modularization IS 101Y/CMSC 101 Computational Thinking and Design Thursday, September 26, 2013 Marie desJardins University.
MC697 Object-Oriented Programming Using Java. In this class, we will cover: How the class will be structured Difference between object-oriented programming.
Processing Processing is a simple programming environment that was created to make it easier to develop visually oriented applications with an emphasis.
Aim: Use the given examples to record examples and our own ideas in our journal 1.Write technical examples in journal and/or participate in full.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
DSA Processing. Links Processing.org My Processing page Ben Fry Ben Fry’s Thesis on Computational Information DesignThesis Casey Reas siteCasey Reas Casey.
1 Applets Chapter 1 To understand:  why applets are used to extend the capabilities of Web pages  how an applet is executed and know about the restrictions.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
1 Python Programming: An Introduction to Computer Science Chapter 3 Objects and Graphics.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
(An Introduction for Programmers)
PROCESSING Animation. Objectives Be able to create Processing animations Be able to create interactive Processing programs.
What is Scratch? Scratch as Logo Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Chapter 3 Working with Symbols and Interactivity.
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
CIS—100 Chapter 9—PowerPoint 1. The PowerPoint User Interface 2 There is a tall band across the screen that contains many, very visual commands arranged.
Introduction to Scratch!
Lehigh University Introduction to Flash MX Sharmeen Mecklai.
BIM211 – Visual Programming Objects, Collections, and Events 1.
Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Visual Basic .NET BASICS
LEARN MICROSOFT POWERPOINT 2010 Westerville Public Library 2014.
Keyboard and Events. What about the keyboard? Keyboard inputs can be used in many ways---not just for text The boolean variable keyPressed is true if.
Processing Lecture.2 Mouse and Keyboard
Designing a Web Page with Tables. A text table: contains only text, evenly spaced on the Web page in rows and columns uses only standard word processing.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 2 Graphics Programming with C++ and the Dark GDK Library Starting.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Chapter Two Creating a First Project in Visual Basic.
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
Introduction to Processing. 2 What is processing? A simple programming environment that was created to make it easier to develop visually oriented applications.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02b: Tutorial for Programming in Processing Jarek Rossignac.
CIS 3.5 Lecture 2.2 More programming with "Processing"
Game Programming Using Scratch Brooklyn College Bridges To Computing (2009) M. Meyer, J. Rodney.
Often being different. Control flow By default Java (and therefore Processing) executes lines of a program one after the other –Doesn’t matter what happened.
Computer Game Design ActionScript is… Object-oriented programming Everything you do in ActionScript does something to some object* Some objects.
Computer Science I Looping. User input. Classwork/Homework: Incorporate looping & user input into a sketch.
G RAPHICS & I NTERACTIVE P ROGRAMMING Lecture 2 More Programming with Processing.
Introduction to Programming Using Scratch Brooklyn College Bridges To Computing (2009) M. Meyer.
Continuous. Flow of Control Programs can broadly be classified as being –Procedural Programs are executed once in the order specified by the code varied.
Review Expressions and operators Iteration – while-loop – for-loop.
What is Computing? What can be Programmed? Creative Computing Processing Downloading Processing Dropbox Primitive Shapes – point – line – triangle – quad.
Web and Multimedia Development Copyright © Genetic Computer School 2007WM LESSON OVERVIEW  Use of Tables  Creating Tables  Try It – 1  Creating.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
CIS 205—Web Design & Development Flash Chapter 3 Working with Symbols and Interactivity.
MOM! Phineas and Ferb are … Aims:
Inserting and Working with Images
Chapter 14, Translate & Rotate
Introduction to Programming Using Scratch
Learning to program with Logo
VISUAL BASIC.
Chapter 10 Algorithms.
Chapter 2 Graphics Programming with C++ and the Dark GDK Library
CIS 3.5, Spring 2010 Lecture II.1 Topics: Internet and WWW Overview
More programming with "Processing"
Working with Symbols and Interactivity
Lecture 7: Introduction to Processing
Using Logo and Logic This presentation uses a version of Logo called StarLogo available through MIT. It can be downloaded for free and installed on your.
Presentation transcript:

G RAPHICS & I NTERACTIVE P ROGRAMMING Lecture 1 Introduction to Processing

R ESOURCES Processing web site: Download Processing Reference:

C ONTENT 1.Graphics Programming 2.Interactive Programming 3.Hexadecimal Color 4.Processing (Introduction) 1.Basics 2.Functions – Custom 3.Functions – Built in, drawing 4.Variables 5.Selection 6.Repetition 5.Don’t Panic

G RAPHICS P ROGRAMMING : Utilizing and/or manipulating images within a computer program. Photoshop Game Programming Digital Movie Creation Windows and GUI are graphics programming. Many programming languages have "graphics libraries" (Direct3D, OpenGL) but the robustness of these libraries can make them difficult to work with. Processing has its own special library of functions that we can use to create 2D and 3D images.

I NTERACTIVE P ROGRAMMING : A movie or television show contains visual images, but you can't change or modify those images. A GAME or INTERACTIVE STORY by contrast does allow the user to change what is shown. Websites are another area where we want INTERACTIVITY as part of our final design links search boxes image maps Interactive Programming is programming that uses special functions to users to modify the behavior of a program. We will officially look at event handlers in the next lecture. But look for the special keyboard handler functions in this lecture.

N OTE ON H EXADECIMAL C OLOR Hexadecimal color is a common color mode used in computer graphics. It’s a very efficient method, using only six digits to identify a single color out of the 16.8 million available on modern computer monitors.

P ROCESSING Why we are going to use it: It's FREE ( Simple (Imperative, Procedural, OO) scripting language. Has excellent built in graphics capabilities. Programs can also be saved as applets and run inside a browser (client side scripting). Powerful library suite. Essentials: Originally written for artists (create narratives, games). Programs in Processing are called sketches. Text-based programming language. Write and run using an integrated development environment (IDE) that is part of Processing.

P ROCESSING – 1 ST P ROGRAM Open processing and type in the following commands just as you see them in the window. Then hit the "run" button in the top bar. The run button is the first of the 6 buttons in the command bar.

C OORDINATE S YSTEM All graphics are drawn using the following coordinate system: Think of it like a piece of graph paper A point fills in one cell on the graph paper A line fills in multiple cells, from one end- point of the line to the other

P ROCESSING P ROGRAMMING B ASICS Programs: Programs are written by typing in text. Programs are processed top-down, left-right (sequence). Special terms and functions exist in the language (semantics). Syntax: Each line contains a statement Statements end with a semi-colon ( ; ) Comments are contained within /** and */ Another way to make comments: // Blocks or related code (part of a function) are specified using curly braces { } Special Functions: Two special functions are part of the syntax and semantics of the language and may only appear ONCE in a program: setup() draw()

P ROCESSING F UNCTIONS Functions: Are blocks of code that have been given a name.. Are called when needed, by using their name. Are an aspect of the procedural paradigm. Provide a way to re-use code. Some functions we will create ourselves: Example: void my_function() { line( 10, 20, 30, 40 ); point(120, 50) } void keyword indicates function returns nothing my_function() = the name of the function curly brackets ( { and } ) delineate beginning and end of the function

D RAW F UNCTIONS ( BUILT - IN, S EMANTICS ) Other Functions are built into the Processing language. Processing has built in functions for creating shapes: point( x, y ) draws one point (looks like a dot...) line( x1, y1, x2, y2 ) connects two points triangle( x1, y1, x2, y2, x3, y3 ) connects three points quad( x1, y1, x2, y2, x3, y3, x4, y4 ) connects four points rect( x, y, width, height ) origin + extent; square if width=height ellipse( x, y, width, height ) origin: center of ellipse’s; circle if width=height arc( x, y, width, height, start, stop ) origin: center of arc’s bounding box (see ellipse) start and stop: can be whole (int) or real (float) numbers (float); expressed in degrees or radians, depending on current angle mode; 0 is due east; measured clockwise.

V ARIABLES A variable is a name and value pair. Variables provide a way to save information so that you can refer to it (use it, change it) later. You may be familiar with variables from studying algebra. Example: 20 = x / 5 What is x? A name for a number whose value is 100 We can create our own variables in Processing. Example: int x = 3; int is the data type and means x is a whole number x is the name of the variable 3 is the value of x Other variables are built into the processing language (part of the semantics of the language) and are controlled/maintained by the OS. Examples: width, height Always indicate the width and height of the screen.

K EYBOARD I NTERACTION F UNCTIONS AND V ARIABLES (B UILT – I N ) Functions keyPressed() handles behavior when user presses a key down keyReleased() handles behavior when user releases a key keyTyped() handles behavior when user types a key (press and release) Variables key indicates which key was pressed/released/typed equals CODED when special key is pressed/released/typed, like an arrow key, shift, control, alt, etc. keyCode indicates special key: UP, DOWN, LEFT, RIGHT, ALT, CONTROL, SHIFT

2 ND P ROGRAM // This is a comment /* So is this */ /** So is this */ void setup() {// Special function, only done once! background( #ffffff );// Changes background color to white. } void draw() {// Special function, repeats over and over! line( 10, 20, 30, 40 );// Draws a line. point( 50, 50 );// Draws a point. } void keyPressed() {// Special function, called by OS. background( #0000ff );// Changes background to blue. }

S ELECTION (I MPERATIVE P ARADIGM ) We will want the ability to make a choice in our programs. 1. Some things we will only want to happen IF something is true. 2. In other cases we will want to choose from more than one option (if – else) 3. At other times we will want to make multiple test at once: || is or && is and if ( test ) { statements } if ( test ) { statements } else { statements } if ( ( test1 ) || ( test2 ) ) { statements}

R EPETITION (I MPERATIVE P ARADIGM ) You may want to repeat an action. Both for and while loops are supported: while (expression) { statements } Example: int i=0; while(i<80) { line(30, i, 80, i); i = i + 5; }

3 RD P ROGRAM void setup() { // This special function is called once at the start background( #ffffff ); } void draw() { // This special function loops over and over line( 10, 20, 30, 40 ); point( 50, 50 ); } void keyPressed() { // This special function is called by the OS if ( key == 'R' || key == 'r' ) { background( #ff0000 ); } else { int i=0; while(i<80) { line(30, i, 80, i); i = i + 5; } }// Notice how we indent the content of loops and functions to help us read the code.

D ON ' T P ANIC We will have several labs on using processing. For those of you with little or no programming experience your final project will not be that hard. Anyone can learn to do simple (and fun) things with processing fairly quickly. NOTE: Processing is FREE software that you can download and run on your machine at home: