Lecture 7: Introduction to Processing

Slides:



Advertisements
Similar presentations
Processing Lecture. 1 What is processing?
Advertisements

Emerging Platform#5: Processing 2 B. Ramamurthy 6/13/2014B. Ramamurthy, CS6511.
Processing Processing is a simple programming environment that was created to make it easier to develop visually oriented applications with an emphasis.
DSA Processing. Links Processing.org My Processing page Ben Fry Ben Fry’s Thesis on Computational Information DesignThesis Casey Reas siteCasey Reas Casey.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
1 Graphical objects We will draw graphics in Java using 3 kinds of objects: DrawingPanel : A window on the screen. Not part of Java; provided by the authors.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
Foundation Programming Introduction. Aims This course aims to give students a basic understanding of computer programming. On completing this course students.
Foundation Flash CS Introduction Welcome to Flash CS3 Professional. You have seen a lot of the great stuff Flash can do and it is now time for.
Click your mouse for next slide Flash – Introduction and Startup Many times on websites you will see animations of various sorts Many of these are created.
Locally Edited Animations We will need 3 files to help get us started at
Learn about the types of Graphics that are available Develop a basic Graphics applet Develop a basic Graphics application Review the Java API and use.
Continuous February 16, Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?
Introduction to Processing CS 4390/5390 Fall 2014 Shirley Moore, Instructor September 3,
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 11 Fall 2010.
Working with Objects. Objectives Create an object Transform an object Arrange and lock an object Step and repeat an object Use Live Distribute Use the.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
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 Building Java Programs Supplement 3G: Graphics These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold,
1 Taif University Faculty Of Computers And Information Technology TA. Kholood Alharthi & TA. Maha Thafar First Semester AH.
Computer Science I Arrays. Parallel structures. Classwork/Homework: Build your own bouncing things.
Computer Science I Recap: variables & functions. Images. Pseudo-random processing.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
CRE Programming Club - Class 5 Robert Eckstein and Robert Heard.
CS305j Introduction to Computing Simple Graphics 1 Topic 11 Simple Graphics "What makes the situation worse is that the highest level CS course I've ever.
Introduction to Graphics. Graphical objects To draw pictures, we will use three classes of objects: –DrawingPanel : A window on the screen. –Graphics.
Continuous. Flow of Control Programs can broadly be classified as being –Procedural Programs are executed once in the order specified by the code varied.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Motion Graphics & Animation.
Welcome to Processing Who does not have access to digital camera?
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
Introduction to Processing Dominique Thiebaut Dept. Computer Science Computer Science Dominique Thiebaut Thiebaut -- Computer Science.
PyGame - Unit 1 PyGame Unit – – Introduction to PyGame.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
Introduction to Processing David Meredith Aalborg University Art &Technology, 3rd Semester Programming.
Sound and more Animations
Modifying GridWorld Classes.
MOM! Phineas and Ferb are … Aims:
Pixels, Colors and Shapes
Adapted from slides by Marty Stepp and Stuart Reges
Flash Interface, Commands and Functions
Building Java Programs
Chapter 14, Translate & Rotate
Building Java Programs
Building Java Programs
Example: Card Game Create a class called “Card”
Building Java Programs
Using the INSERT TAB in MS Word 2007
CSc 110, Spring 2017 Lecture 6: Parameters (cont.) and Graphics
Basic Graphics Drawing Shapes 1.
Flash animation For beginners.
Building Java Programs
Chapter 10 Algorithms.
Chapter 10 Algorithms.
Lecture 4: Introduction to Processing AP Computer Science Principles
Lecture 7: Methods AP Computer Science Principles
Simple Graphics Package
Lecture 11: Classes AP Computer Science Principles
Building Java Programs
Building Java Programs
Building Java Programs
Chapter 10 Algorithms.
Building Java Programs
Building Java Programs
Continuous & Random September 21, 2009.
Graphics Reading: Supplement 3G
Agenda for Unit 5: Control Structures
Animation Translation.
Presentation transcript:

Lecture 7: Introduction to Processing

Processing Processing started by Ben Fry and Casey Reas while both were graduate students at MIT Media Lab in 2001. Processing is Java. Designed for visual artists with limited programming experience who want to create art, animation and games without knowing complicated Java syntax. In its current version, hundred of libraries have been written for computer vision, data visualization, music composition, networking, 3D drawings, programming electronics, etc…

Processing A program, called a sketch, in Processing, at its most basic, consists of just two methods: setup() and draw(). setup(): initializing variables, setting up window size, etc… draw(): repeats 60 times a second(60hz refresh rate), responsible for the animation and flow of a program.

A basic sketch // global variables are declared at the top before setup() void setup(){ // code here to initialize global variables, // background color, window size, etc… // setup() is run only once. } // draw is a loop that runs // automatically 60 frames per second // used for animation void draw(){ // code for updating variables for next frame // creating illusion of animation

Example int x; //declaring global variables; not initialized void setup(){ //initializing x and y x = 5; } void draw() { x = x + 1; //x increases by 1 // 60 times per second.

Coordinate System

Example 1 Note: Red-colored text denotes reserved methods or variables. int centerX, centerY; void setup(){ size(800,600); // window width=800 pixels, height=600 pixels centerX = width/2; // 400 centerY = height/2; // 300 } void draw(){ background(255); //white background fill(255,0,0); //red fill (Red,Green,Blue) color (RGB) ellipse(centerX,centerY,80,80); //red circle radius 40(diameter=80)

Making it move! int centerX, centerY, xspeed; void setup(){ size(800,600); // window width=800 pixels, height=600 pixels centerX = width/2; // 400 centerY = height/2; // 300 xspeed = 5; } void draw(){ background(255); //white background fill(255,0,0); //red fill (Red,Green,Blue) color (RGB) //red circle radius 40 (diameter=80) ellipse(centerX,centerY,80,80); centerX = centerX + xspeed; //updating centerX

Back and Forth int centerX, centerY, xspeed; void setup(){ size(800,600); // window width=800 pixels, height=600 pixels centerX = width/2; // 400 centerY = height/2; // 300 xspeed = 5; } void draw(){ background(255); //white background fill(255,0,0); //red fill (Red,Green,Blue) color (RGB) //red circle radius 40 (diameter=80) ellipse(centerX,centerY,80,80); centerX = centerX + xspeed; //updating centerX if (centerX > width || centerX < 0) { xspeed = -xspeed;

Processing References The Processing website is a great reference for learning about Processing. There are tutorials on different topics, videos, etc… A quick way to learn how to do something on Processing is through Google. If I want to know how to draw a rectangle. Search for “draw rectangle processing”, the first result will take you directly to the code on Processing. There are also many videos on Processing on youtube.

Lab 1 Download Processing at https://www.processing.org/. Retype the previous program to see the ball bouncing back and forth. Please, for this first time, DO NOT copy and paste. Practice learning how to do this without any reference. Modify the program so that the ball has a vertical velocity component by adding a vertical speed, yspeed. Add an “if” conditional to make sure the ball bounces of the top and bottom of the screen.

Lab 1(continued) Some more things to try. Play around with the window size. Try changing the background into RGB color instead of greyscale.

Lab 1(continued) As the program is written here, the ball does not perfectly bounces off the edge of the window. Fix it by introducing a radius variable! Write your program so that the ball bounces correctly for any window size and for any radius without explicitly fixing your code.

Lab 2 void draw(){ background(255); drawBall(); moveBall(); Refactor your code from the ball bouncing program now to include three methods: void drawBall(){…} void moveBall(){…} void bounceBall(){…} Your draw() method should now be very simple: void draw(){ background(255); drawBall(); moveBall(); bounceBall(); }

Lab 3 We won’t specifically cover Processing’s API in class lectures. Some of this will be covered in your homework by watching youtube videos. Watch the first two videos(Drawing Basic Shapes and Basic Animation) of the Introduction to Processing Series on my Youtube channel. See links on my website. Write a sketch that: Draw a circle, a line, a rectangle, a square of different sizes and color. Add some text to the screen. Draw a shape that follows your mouse. Use beginShape() to draw any polygon with 6 sides.