An Introduction to Processing

Similar documents
Using Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Using Methods. More on writing methods. Dr. Siobhán Drohan Mairead Meagher. Produced by: Department of Computing and Mathematics

Using Methods. Writing your own methods. Dr. Siobhán Drohan Mairead Meagher. Produced by: Department of Computing and Mathematics

Conditional Events. Mouse events and Operators. Dr. Siobhán Drohan Mairead Meagher. Produced by:

Iteration in Programming

CISC 1600 Lecture 3.1 Introduction to Processing

THE JAVASCRIPT ARTIST 15/10/2016

c.def (pronounced SEE-def) Language Reference Manual

An Introduction to Processing

We will start our journey into Processing with creating static images using commands available in Processing:

Basic Computer Programming (Processing)

1. Complete these exercises to practice creating user functions in small sketches.

Class #1. introduction, functions, variables, conditionals

Practice Written Examination, Fall 2016 Roger B. Dannenberg, instructor

CISC 1600, Lab 2.1: Processing

The Processing language. Arduino and Processing.

mith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut

Interaction Design A.A. 2017/2018

1 Getting started with Processing

CISC 1600, Lab 3.1: Processing

Topic 8 Graphics. Margaret Hamilton

Adobe Flash CS3 Reference Flash CS3 Application Window

Solution Notes. COMP 151: Terms Test

1. (10 pts) Order the following three images by how much memory they occupy:

1 Getting started with Processing

EXAMINATIONS 2017 TRIMESTER 2

GRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing

To specify the dimensions of the drawing canvas use the size statement: ! size( 300, 400 );

EXAMINATIONS 2016 TRIMESTER 2

Generating Vectors Overview

255, 255, 0 0, 255, 255 XHTML:

Introduction to Processing

CSc 110, Spring 2018 Lecture 9: Parameters, Graphics and Random. Adapted from slides by Marty Stepp and Stuart Reges

Customisation and production of Badges. Getting started with I-Color System Basic Light

University of Cincinnati. P5.JS: Getting Started. p5.js

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

Loops. Variable Scope Remapping Nested Loops. Donald Judd. CS Loops 1. CS Loops 2

Geometry. Set 1. Daily Practice And Answer Keys

mith College Computer Science CSC103 How Computers Work Week 6 Fall 2017 Dominique Thiébaut

PyGame Unit ?

classroomsecrets.com Reasoning and Problem Solving Geometry: Shape Sort 2D Shapes Teaching Information

ITEC185. Introduction to Digital Media

Paint/Draw Tools. Foreground color. Free-form select. Select. Eraser/Color Eraser. Fill Color. Color Picker. Magnify. Pencil. Brush.

This is a structured tutorial demonstrating the features of the GEdit system. The tutorial guides the designer through three structured examples.

Topic 8 graphics. -mgrimes, Graphics problem report 134

Unit 21 - Creating a Navigation Bar in Macromedia Fireworks

The way I feel about music is that there is no right and wrong. Only true and false. Fiona Apple. true false false

After saving out your Rhino model as an IGES file: Open up Maya Go to File - Import

Appendix F: Java Graphics

Adobe Illustrator. Always NAME your project file. It should be specific to you and the project you are working on.

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

Functions. Functions. nofill(); point(20, 30); float angle = map(i, 0, 10, -2, 2); parameters return values

There s already a ton of code written called libraries that we can use by importing. One that we use often is random

Appendix F: Java Graphics

Ancient Cell Phone Tracing an Object and Drawing with Layers

What can we do with Processing? Let s check. Natural Language and Dialogue Systems Lab Guest Image. Remember how colors work.

3. Area and perimeter.notebook November 13, All rectangles with area 12cm 2 have the same perimeter. True or false?

Kimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013

[ the academy_of_code] Senior Beginners

The American University in Cairo. Academic Computing Services. Excel prepared by. Maha Amer

Creating Digital Illustrations for Your Research Workshop III Basic Illustration Demo

Microsoft Visio Working with Shapes

Animations that make decisions

CS Problem Solving and Object-Oriented Programming

In this lesson you are going to create a drawing program similar to Windows Paint. 1. Start with a new project and remove the default cat sprite.

InDesign Tools Overview

Building Java Programs

CS7026 CSS3. CSS3 Graphics Effects

Variables One More (but not the last) Time with feeling

GIMP WEB 2.0 ICONS. Web 2.0 Icons: Circle Completed Project. Notice that the default new layer background fill is transparency. Click the Ok button.

Programming Fundamentals

Drawing a Circle. 78 Chapter 5. geometry.pyde. def setup(): size(600,600) def draw(): ellipse(200,100,20,20) Listing 5-1: Drawing a circle

With the help of Adobe and a dash of creativity, we can create all kinds of fun things just using the shapes found in our tool box.

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.

CS 100 Python commands, computing concepts, and algorithmic approaches for final Fall 2015

CSC 101: Lab Manual#11 Programming Turtle Graphics in Python Lab due date: 5:00pm, day after lab session

How to Make a VisiMap A Guide for the Absolute Beginner

EXCEL 2003 DISCLAIMER:

Creating a Java class with a main method

Building Java Programs

Introduction To Inkscape Creating Custom Graphics For Websites, Displays & Lessons

Scalable Vector Graphics (SVG) vector image World Wide Web Consortium (W3C) defined with XML searched indexed scripted compressed Mozilla Firefox

How to...create a Video VBOX Gauge in Inkscape. So you want to create your own gauge? How about a transparent background for those text elements?

Staged problem solving. Blue card sort. Areas of Circles: Staged Problem solving. Card sort, structured stages, independence

5. Introduction to Procedures

Building Java Programs

OnPoint s Guide to MimioStudio 9

Graphing Single Subject Research Data. AAC Colloquium October 18 th, 2017

CSC 1051 Data Structures and Algorithms I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University

03 Vector Graphics. Multimedia Systems. 2D and 3D Graphics, Transformations

Texture Mapping. Images from 3D Creative Magazine

Interactive Tourist Map

Things to check before you join a Collaborate session

Preparation: Get to know the Java coordinate system. 3. How is the background color of the window specified? Copy the exact code:

Introduction to Google SketchUp

HO-FL1: INTRODUCTION TO FLASH

MathUtilities.randomInt(min, max) function unit conversions, simple drawings

Final Exam Winter 2013

TUTORIAL 03: RHINO DRAWING & ORGANIZATIONAL AIDS. By Jeremy L Roh, Professor of Digital Methods I UNC Charlotte s School of Architecture

This document should only be used with the Apple Macintosh version of Splosh.

Transcription:

An Introduction to Processing Creating static drawings Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/

Topics list Coordinate System in Computing. Functions in Processing. Basic Shapes. Formatting the display window. Syntax Errors. Logic Errors.

Coordinate System in Computing In Geometry, we use this type of coordinate system: In Computing, we use this type of coordinate system to represent the screen: point (0,0) is in the centre. point (0,0) is in the top left hand corner. Each number is a pixel. https://processing.org/

Coordinate System in Computing Run button So how does this relate to Processing? When you open Processing and click on the run button, a display window pops up. Display window

Coordinate System in Computing The display window is where your code is run/ displayed. It follows the rules of the Computing coordinate system i.e. the top left hand corner is (0,0). A point (10,20) is 10 pixels to the right of (0,0) and 20 pixels below (0,0). (0,0) Display window

Topics list Coordinate System in Computing. Functions in Processing. Basic Shapes. Formatting the display window. Syntax Errors. Logic Errors.

Functions in Processing Processing comes with several pre-written functions that we can use. A function comprises a set of instructions that performs some task. When you call the function, it performs the task. We will now look at functions that draw the following shapes: Rectangle, square, line, oval and circle.

Topics list Coordinate System in Computing. Functions in Processing. Basic Shapes. Formatting the display window. Syntax Errors. Logic Errors.

rect() https://processing.org/

rect() drawing a rectangle

rect() drawing a square Note how each line of code has a semi-colon (;) at the end of it. This is called a statement terminator and must be included.

rect() syntax rect(x, y, w, h) x = x-coordinate of the upper left corner of the rectangle y = y-coordinate of the upper left corner of the rectangle w = width of the rectangle h = height of the rectangle The rect function above defines four parameters i.e. x, y, w, h. When you call rect, you are expected to pass four numbers to it. These actual numbers are called arguments. rect uses these four numbers to render the rectangle on the display window. To draw a square, the width and height must be the same value.

line() https://processing.org/

line () drawing a line

line() syntax line(x1, y1, x2, y2) x1 = x-coordinate of first point y1 = y-coordinate of first point x2 = x-coordinate of second point y2 = y-coordinate of second point

ellipse() https://processing.org/

ellipse()

ellipse()

ellipse() syntax ellipse(x, y, w, h) x = x-coordinate of the centre of the ellipse y = y-coordinate of the centre of the ellipse w = width of the ellipse h = height of the ellipse To draw a circle, the width and height must be the same value.

Topics list Coordinate System in Computing. Functions in Processing. Basic Shapes. Formatting the display window. Syntax Errors. Logic Errors.

Formatting the display window Our display window is looking fairly cramped. The default size of your display window is 100x100 pixels, which is quite small.

Formatting the display window We can change the size of the display window by calling the size function. When you use the size function in static drawings, it has to be the first line of code in your sketchbook. size(w, h) w = width of the display window h = height of the display window

size()

Formatting the display window Our display window looks less cramped now. But the default gray colour is not very appealing. We could use the background function to set the colour to something nicer.

A note on colour first Grayscale 0 means black, 255 means white. In between, every other number - 50, 87, 162, 209, and so on - is a shade of gray ranging from black to white. https://www.processing.org/tutorials/color/

A note on colour first RGB As with grayscale, the individual color elements are expressed as ranges from 0 (none of that color) to 255 (as much as possible), and they are listed in the order R, G, and B. Digital colours are made by mixing the three primary colours of light (red, green, and blue). https://www.processing.org/tutorials/color/

A note on colour first RGB As with grayscale, the individual color elements are expressed as ranges from 0 (none of that color) to 255 (as much as possible), and they are listed in the order R, G, and B. Digital colours are made by mixing the three primary colours of light (red, green, and blue). https://www.processing.org/tutorials/color/

A note on colour first RGB http://www.colorschemer.com/online.html

background() - syntax background(grayscale) grayscale = grayscale colour (a number between 0 [black] and 255 [white] inclusive) background(r, g, b) r = red colour (a number between 0 and 255 inclusive) g = green colour (a number between 0 and 255 inclusive) b = blue colour (a number between 0 and 255 inclusive)

background()

background()

Topics list Coordinate System in Computing. Functions in Processing. Basic Shapes. Formatting the display window. Syntax Errors. Logic Errors.

Syntax and Syntax Errors You will have seen the term Syntax mentioned above. Syntax are the rules you must follow when writing well-formed statements in a programming language. When you don t follow the rules, Processing will not run your code; instead you will get an error. Some syntax error examples are on the upcoming slides.

Syntax Errors The spelling of the background function must be identical to the spelling below (case sensitive!). background(r, g, b) r = red colour (a number between 0 and 255 inclusive) g = green colour (a number between 0 and 255 inclusive) b = blue colour (a number between 0 and 255 inclusive)

Syntax Errors The background function has too many arguments passed to it i.e. RGB version is defined with 3 parameters. Grayscale version is defined with 1 parameter. background(r, g, b) r = red colour (a number between 0 and 255 inclusive) g = green colour (a number between 0 and 255 inclusive) b = blue colour (a number between 0 and 255 inclusive)

Syntax Errors The semi-colon (;) is missing at the end of the statement. Java needs a statement terminator for each line! background(r, g, b) r = red colour (a number between 0 and 255 inclusive) g = green colour (a number between 0 and 255 inclusive) b = blue colour (a number between 0 and 255 inclusive)

Topics list Coordinate System in Computing. Functions in Processing. Basic Shapes. Formatting the display window. Syntax Errors. Logic Errors.

Logic Errors

Logic Errors Say we wanted a pink background for our display window. However, we incorrectly enter the G colour as 551 instead of 51. We now have a yellowish background. This is an example of a simple logic error.

Questions?

Department of Computing and Mathematics http://www.wit.ie/