Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.

Slides:



Advertisements
Similar presentations
Creative Computing. \\ aims By the end of the session you will be able to: 1.Move objects around 2.Write simple interactive programs 3.Use the mouse position.
Advertisements

Create a Simple Game in Scratch
Variables Conditionals Boolean Expressions Conditional Statements How a program produces different results based on varying circumstances if, else if,
Lesson One: The Beginning Chapter 3: Interaction Learning Processing: by Daniel Shiffman Presentation by Donald W. Smith Graphics from text.
Create a Simple Game in Scratch
Lesson One: The Beginning
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 and Operators
Emerging Platform#5: Processing 2 B. Ramamurthy 6/13/2014B. Ramamurthy, CS6511.
© Calvin College, Being abstract is something profoundly different from being vague... The purpose of abstraction is not to be vague, but to create.
 Variables  What are they?  Declaring and initializing variables  Common uses for variables  Variables you get “for free” in Processing ▪ Aka: Built-in.
Processing Processing is a simple programming environment that was created to make it easier to develop visually oriented applications with an emphasis.
IAT 334 Java using Processing ______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY.
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.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
IAT 800 Foundations of Computational Art and Design ______________________________________________________________________________________ SCHOOL OF INTERACTIVE.
Lecture 3 IAT 800. Sept 15, Fall 2006IAT 8002 Suggestions on learning to program  Spend a lot of time fiddling around with code –Programming is something.
Review Blocks of code {.. A bunch of ‘statements’; } Structured programming Learning Processing: Slides by Don Smith 1.
LCC 6310 Computation as an Expressive Medium Lecture 1.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Art 315 Lecture 4 Dr. J. Parker AB 606 Today’s class: Programming! We are going to write some simple programs. We will use a tool called GameMaker –It.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 8 Fall 2010.
Introduction to Programming with Java. Overview What are the tools we are using – What is Java? This is the language that you use to write your program.
Intro to Java & Processing. Review CS is about problem-solving CS is about problem-solving To write programs you must To write programs you must –Be able.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 11 Fall 2010.
Art 321 Lecture 7 Dr. J. Parker. Programming In order to ‘make things happen’ on a computer, you really have to program it. Programming is not hard and.
______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY [SIAT] |
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.
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.
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
CIS 3.5 Lecture 2.2 More programming with "Processing"
2-D Shapes, Color, and simple animation. 7 Basic Shapes Ellipse :: ellipse() Arc :: arc() Line :: line() Point :: point() Rectangle :: rect() Triangle.
Lesson Two: Everything You Need to Know
Variables Art &Technology, 3rd Semester Aalborg University Programming David Meredith
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
Mouse Inputs in Processing. Interacting with the Mouse mouseX and mouseY: pg mouseXmouseY –The position of the mouse in the canvas pmouseX and.
Lesson Two: Everything You Need to Know
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 Drawing pictures … It’s not art, it’s fun.
Computer Science I Recap: variables & functions. Images. Pseudo-random processing.
G RAPHICS & I NTERACTIVE P ROGRAMMING Lecture 2 More Programming with Processing.
CRE Programming Club - Class 5 Robert Eckstein and Robert Heard.
Continuous. Flow of Control Programs can broadly be classified as being –Procedural Programs are executed once in the order specified by the code varied.
Welcome to Processing Who does not have access to digital camera?
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
Programming for Art: Arrays – 2D ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 16 Fall 2010.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Variables. Something to mention… void setup(){ size(200, 200); background(255); smooth(); } void draw() { stroke(0); strokeWeight(abs(mouseX-pmouseX));
Introduction to Processing David Meredith Aalborg University Art &Technology, 3rd Semester Programming.
MOM! Phineas and Ferb are … Aims:
Scratch for Interactivity
Processing Introduction CSE 120 Spring 2017
Lesson One: The Beginning Chapter 1: Pixels Learning Processing Daniel Shiffman Presentation by Donald W. Smith Graphics from
Basic Graphics Drawing Shapes 1.
Processing and Drawing CSE 120 Winter 2018
For Net Art Lecture 2 J Parker
Programming for Artists
Mouse Inputs in Processing
Chapter 2 Graphics Programming with C++ and the Dark GDK Library
More programming with "Processing"
Lecture 7: Introduction to Processing
Processing Environment
Creating a Simple Game in Scratch
Presentation transcript:

Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010

Intro to Processing In the previous lecture we discussed scripting, in which the program is specified by typing text. The text represents something to be carried out, a process. The text has a specific structure that allows it to be unambiguous about the process being described. Processing uses scripts only. This is programming in the sense that even engineers are used to.

Processing A script is a test version of a program in Game Maker, and is attached to an object, like a sprite. A script has to communicate the same things as does the point-and-click mouse program, so there must be symbols (text) that do this. A script (program) is written in a scripting language (programming language), which has a fixed set of these symbols and has a syntax (structure). Scripts are the more familiar type of computer program.

Running Processing Click on Processing.exe (in windows) Now type the program into the white part Or copy and paste it from a text file. Or use File->Open

Running Processing Here’s a simple Processing program. It calls a function that draws an ellipese. Run it by pressing the start button.

First Program Draws a circle (a degenerate ellipse) at (50,50) in a default window.

Errors Errors in the program results in an error message for you (missing ‘;’) And one for a Java programmer. This system is written in Java, and gives Java errors.

Errors We can get errors in GameMaker too. This type, a compilation error, is the result of a typing mistake or misunderstanding of the sequence of things needed in the program. Syntax; program can’t execute until the grammar and punctuation is right.

Errors Unexpected token: null What the hell does that mean? Are we not simply missing a ‘;’? The Processing system does not know what we are missing or exactly what is wrong. If it did, it could fix it. All it knows is that it got to the end of your text and seemed to Not be done yet. Reached the end of the file and did not have a Complete program. Expected more, got ‘null’.

Errors Computer reported errors are frequently like this. There are two reasons: 1. As we stated, the program can’t always figure out what is wrong, only what it expected next or what it did not get. 2. The programmers writing these systems do not have a good idea of the context of the system of the user. Error messages must be written using the user’s vocabulary and expressing concepts in a form that follows the user’s view of the system.

Errors Nothing we can do, so we need to live with it.

Processing All programs in processing are scripts. All output is as graphics. This is unlike other languages, where output is text by default and graphics is hard.

Basic Code We have seen a simple program. All it did was to use a function to draw an ellipse. The first thing we need to do is to become familiar with the stable of built-in operations offered by Processing. Then we don’t have to look them up all of the time. ellipse is one such built-in

Coordinates The coordinates used in Processing are those of GameMaker. 0,0 is upper left. These are screen coordinates. (0,0) Y increasing X increasing

Essential Functions line (15, 25, 100, 100) Draws a line between the two points specified as (x,y) values. point (120, 180) Draws a single point. rect (ulx, uly, lrx, lry) Draws a rectangle ellipse (x, y, xx, yy) Draws an ellipse Look up: triangle, quad, curve, arc

Essential Functions size (640, 480) Make the window 640 pixels wide by 480 high. background (255, 0, 0) Sets background color (to red in this case). stroke (0, 0, 200) Sets line (stroke) color. (To blue, in this case) nostroke() means none. fill (0, 255, 0) Sets fill color (green here) nofill() means do not fill. You all OK with RGB color??

Drawing Modes – Rect, Ellipse Specifying a rectangle can be done 3 ways: Default: CORNER upper left coordinates and the height and width are specified CENTER: the coordinates of the center, plus width and height are specified. CORNERS : upper left/lower right are specified

Drawing Modes – Rect, Ellipse CORNER rect(2,2,5,3) CENTER rect(2,2,5,3) CORNERS rect(2,2,5,3) (2,2) Width, height

Drawing Modes – Rect, Ellipse CORNER rect(2,2,5,3) CENTER rect(2,2,5,3) CORNERS rect(2,2,5,3) (2,2) Width, height

Drawing Modes – Rect, Ellipse CORNER rect(2,2,5,3) CENTER rect(2,2,5,3) CORNERS rect(2,2,5,3) (2,2) lrx, lry (5,3)

Drawing Cartoons are often made from simple shapes. Perhaps we can make an approximation to Bender using what we know about Processing

Bender Our version in Processing is not identical to the template, or course. This is done by simply drawing primitive objects in the right places. Pretty dull.

Bender // Jim Parker // Art 315 // Fall 2010 // Bender! size (300, 300); background (128); stroke (0); fill(190); // Antenna triangle (187, 100, 191, 40, 195, 100); ellipse (191, 39, 8, 8); ellipseMode (CORNERS); ellipse (176, 100, 205, 128); // Head ellipse (138, 108, 238, 170); rectMode (CORNERS); rect (139, 131, 236, 280); // Visor ellipse (122, 157, 155, 205); ellipse (210, 155, 255, 205); line (135, 157, 230, 156); noStroke (); rect (135, 158, 158, 205); rect (210, 157, 240, 206); stroke (0); line (141, 213, 238, 212); line (125, 194, 143, 213); line (252, 190, 238, 212); // Erase noStroke (); triangle (126, 193, 142, 212, 145, 201); triangle (251, 190, 236, 211, 235, 200); stroke(255); fill (0); stroke (0); ellipse (128, 161, 154, 197); ellipse (226, 160, 250, 196); rect (141, 161, 240, 197); line (141, 161, 239, 160); line (144, 197, 240, 197); noStroke (); // Eyes fill (255); ellipse (139, 167, 181, 199);

Bender (continued) // Vertical teeth line (173, 230, 173, 266); line (187, 230, 187, 266); line (202, 230, 202, 266); line (148, 245, 159, 242); line (159, 242, 173, 241); line (173, 241, 187, 241); line (187, 241, 202, 242); line (202, 242, 216, 242); line (216, 242, 226, 244); line (148, 256, 159, 254); line (159, 254, 173, 253); line (173, 253, 187, 253); line (187, 253, 202, 253); line (202, 253, 216, 254); line (216, 254, 222, 256); ellipse (200, 166, 240, 199); fill (0); rect (144, 180, 150, 186); rect (205, 180, 211, 186); // Mouth stroke (0); fill (255); ellipse (146, 230, 181, 265); ellipse (146, 246, 165, 265); ellipse (200, 230, 227, 264); rect (159, 230, 216, 265); noStroke (); // Erase ellipse (146, 240, 159, 263); stroke (0);

Bender This is not how Processing code is generally written, but it does give us a chance to become familiar with the basic drawing stuff. Processing has variables, functions, events, IF statements, and flow of control, just as GameMaker does and as does C and Java.

Processing Modes Processing operates in static mode or dynamic mode. In static mode, processing draws a picture on the screen. (EG bender) In dynamic mode it draws pictures repeatedly, in succession. IE animation, as in GameMaker.

Dynamic Mode Involves two parts. 1.An initialization step that is always executed once, at the beginning of the program. 2.A drawing step, that happens every fraction of a second. We need to write code for both parts.

Dynamic mode Initialization step is named setup: void setup () { // initialization here } These enclose the script that does the initialization. Like the triangles In GameMaker. Void? Parentheses?

Dynamic mode Initialization step is named setup: void setup () { size (300, 400); } Example: set the window size once, at the beginning of the program.

Dynamic Mode Drawing at each step. void draw () { // Stuff that draws things each iteration. // Runs forever. }

Dynamic Mode Drawing at each step. void draw () { int x, y; background (200); stroke (0); fill (175); rectMode (CENTER); rect (20, 30, 50, 50); rect (30, 90, 50, 50); }

Output This is a static drawing. It does Not show off the animation. Lets draw the rectangles where the mouse cursor is.

Mouse void draw () { background (200); stroke (0); fill (175); rectMode (CENTER); rect mouseX, mouseY, 50, 50); } mouseX and MouseY are Variables defined by the system. They are like those in GameMaker.

Output

Let’s make a small change … void setup() { size(300,400); background (200); } void draw () { // background (200); stroke (0); fill (175); rectMode (CENTER); rect (mouseX, mouseY, 50, 50); } Move the background call From ‘draw’ to ‘setup’. What will happen??

Explain??

Variables Variables need to be declared before they can be used. Declarations are simple, and merely tell Processing that the name is to be used and what kind of thing it can contain (an integer? Character? Real number?)

Variables Here’s an example: float r, g, b, a; void setup () { size (200, 200); background (0); smooth(); } void draw () { r = random (255); g = random (255); b = random (255); a = random (255); noStroke (); fill (r,g,b,a); ellipse (random (200), random(200), 20, 30); }

Output

New things -Cause the size of the ellipses to vary too. -Draw rectangles too. -Specify colours – red range, blue range, etc. -** Color depends on mouse position **