Class #1. introduction, functions, variables, conditionals

Similar documents
1 Getting started with Processing

1 Getting started with Processing

CISC 1600 Lecture 3.1 Introduction to Processing

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

Design Programming DECO2011

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

[ the academy_of_code] Senior Beginners

Basic Computer Programming (Processing)

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

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

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

An Introduction to Processing

CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM

CS110 Introduction to Computing Fall 2016 Practice Exam 1 -- Solutions

Solution Notes. COMP 151: Terms Test

CSC 120 Introduction to Creative Graphical Coding, Fall 2017

Variables. location where in memory is the information stored type what sort of information is stored in that memory

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

Exploring Processing

Repetition is the reality and the seriousness of life. Soren Kierkegaard

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

CSC 120 Introduction to Creative Graphical Coding, Fall 2015

Interactive Tourist Map

Khan Academy JavaScript Study Guide

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

Interaction Design A.A. 2017/2018

Interaction Design A.A. 2017/2018

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

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

EXAMINATIONS 2016 TRIMESTER 2

EXAMINATIONS 2017 TRIMESTER 2

Reviewing all Topics this term

Creating objects TOPIC 3 INTRODUCTION TO PROGRAMMING. Making things to program with.

CS110 Introduction to Computing Fall 2016 Practice Exam 1

CSE120 Wi18 Final Review

COSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan

Processing & Arduino in Tandem. Creating Your Own Digital Art Tools

StudentSignature: Student Number: Your Computer Number. Concepts for Advanced Computer Usage.

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI

Program Fundamentals

CIS 110: Introduction to Computer Programming

Outline. Turtles. Creating objects. Turtles. Turtles in Java 1/27/2011 TOPIC 3 INTRODUCTION TO PROGRAMMING. Making things to program with.

The C++ Language. Arizona State University 1

GRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing

CMPT-166: Sample Midterm

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:

WEEK 4 OPERATORS, EXPRESSIONS AND STATEMENTS

CS 231 Data Structures and Algorithms, Fall 2016

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

Variables and Control Structures. CS 110 Eric Eaton

Pick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1

What is a variable? a named location in the computer s memory. mousex mousey. width height. fontcolor. username

Introduction to Processing. Sally Kong

Computer Programming : C++

CSE 142 Su 04 Computer Programming 1 - Java. Objects

Iteration in Programming

Computer Vision. Matlab

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

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, February 2 nd, before 6 PM Out of 100 points

Homework #2: Introduction to Images Due 4 th Week of Spring 2018 at the start of lab CSE 7, Spring 2018

CISC 1600, Lab 3.1: Processing

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?

Key Differences Between Python and Java

Lecture 7. Processing Development Environment (or PDE)

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

C++ Support Classes (Data and Variables)

What is a variable? A named locajon in the computer s memory. A variable stores values

CISC 1600, Lab 2.1: Processing

Our Strategy for Learning Fortran 90

Name CMPS 5J Final March 17, 2009 This is a closed notes, closed book exam.

Yup, left blank on purpose. You can use it to draw whatever you want :-)

Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Lesson 6A Loops. By John B. Owen All rights reserved 2011, revised 2014

I put a shortcut onto your desktop, the screen that you look at after you log in.

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

MODULE 02: BASIC COMPUTATION IN JAVA

4. Java Project Design, Input Methods

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

PLT Fall Shoo. Language Reference Manual

Interaction Design A.A. 2017/2018

HTML/CSS Lesson Plans

Topics for section today. Homework 10 functions for loops and loading fonts

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

Photogram. Programmable Photoshop Language Language Reference Manual. ( ), Group Leader. (

THE JAVASCRIPT ARTIST 15/10/2016

Course Outline. Introduction to java

Java+- Language Reference Manual

RENDERING TECHNIQUES

BB4W. KS3 Programming Workbook INTRODUCTION TO. BBC BASIC for Windows. Name: Class:

2D Shapes. Creative Coding & Generative Art in Processing 2 Ira Greenberg, Dianna Xu, Deepak Kumar

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

Python: common syntax

if / if else statements

EXPRESSIONS AND ASSIGNMENT CITS1001

Full file at

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Assignment 2. Application Development

Homework Set 1- Fundamentals

Transcription:

Class #1 introduction, functions, variables, conditionals

what is processing hello world tour of the grounds functions,expressions, statements console/debugging drawing data types and variables decisions homework

What is processing programming language development environment software that lets you write other software

What is processing good for software sketchbook - good for prototyping extendible with JAVA if needed designed for artists and designers

nice things about processing open source syntactically derived from popular languages low overhead to get started well documented online

hello world! size(200,200); background(150);

sketches processing projects are called sketches each sketch has its own folder that contains the sketch and associated files preferences will show where sketch folders are located

export creates all the files needed to put your program on the internet export application creates a stand alone application

Comments // single comment / * */ multiple line comment useful for remembering what the heck you re doing handy for debugging

Two functions size (100, 300) // creates a window 100 pixels wide and 300 pixels tall background (150) // sets the background color to grey

Functions functions command the computer to do all kinds of actions - draw shapes, set colors, perform calculations etc usually lowercase word followed by parentheses myfunction ();

Parameters The parentheses contain the parameters Functions can have none, one, or many parameters Parameters affect how the function works

expressions combination of operators such as +, -, *, / that operate on values from left to right expression always has a value found by evaluating it s contents 5 5 5-14 -9 ((3+2) * 12) 60

comparison expressions can also compare two values 5 > 6 False 8 > (14-10) True

statements combination of expressions creates a statement. statement is the programming equivalent of a sentence must end in a semicolon ; many kinds of statements

some example statements size (200, 200); int x; x = 400;

notes processing is case sensitive processing is not white space sensitive don t forget those semi-colons

console a nice place for you to hang out and chat with your program very useful for debugging and in general figuring out what your program is doing

print() and println() print ( this class sux ); println (1); println (2); println (3);

debugging save working versions divide and conquer retreat to last known working state

Pixels Pixels, also known as picture elements are the elementary building blocks of the universe. The computer screen is a grid of pixels Using processing, we ll achieve TOTAL PIXEL CONTROL

Size (x, y) size (x, y) sets the size of the window of our program in pixels. don t forget the semi-colon

Coordinate system screen position is given by an x position (horizontal) and y position (vertical). point of origin is the upper left corner values increase going down and going right position is given by writing first the x position, then a comma, then the y (12, 78)

Primitives drawing a shape with code is weird because you have to say where everything goes with number

Point point (x, y) setting a point off screen will make it magically not appear

line and friends line(x1, y1, x2, y2) x1 and y1 are starting cords, x2 and y2 are ending cords triangle (x1, y1, x2, y2, x3, y3) quad (x1, y1, x2, y2, x3, y3, x4, y4)

rect and ellipse rect and ellipse have their own thing going on rect (x, y, width, height); ellipse (x, y, width, height);

Bezier really has its own thing going on

Drawing order just like real life, whatever you draw last ends up on top if you execute background() it draws over whatever you drew before

grey values 8 bit graphic, 0 to 255 background (0); // black background (255); // white background (122); // one of 253 lovely shades of grey

fill and stroke fill () sets the color the shape is filled with stroke () sets the outline color nostroke () turns off outlines fill and stroke affect all proceeding drawing commands. call fill and stroke again to change values optional second value affects transparency

save() save( my_picture.jpg ); documents/processing/mysketch

data population of the lab, average grade, mouse clicks, user name, etc stored as numbers and characters store the location of a shape, track user activity

data types numbers, letters, words, colors, images, fonts, boolean values different kinds of data need more or less space allocation memory locations can be interpreted as various things. 01000001 = 41 = A

variables container for holding data specific data type two parts - name and value must be declared before used

declaration states the data type and name int x int x = 4 float y = 4.0002 float x, y, z

don t 5 = 12 //assign a constant to another constant int x = 2.5 //assign a float to an int redeclare the same variable use a reserved word as a variable name start variable with a number

do use descriptive, self-documenting names have fun start name with a lower letter, if there are multiple words, capitalize the start of each word myradvariable

scope Where you declare your variable affects where you can use it. More on this later

Math expressions to the right of = are evaluated before value is assigned to the left int a = 5 + 9 // a = 14 a = a + 10 // a was 14, now a = 24

ints and floats float corrupts int 4/3 = 1 (int with int = int) 4.0 / 3.0 = 1.3333334 (float with float = float) 4/3.0 = 1.3333334 (int with float = float)

int and float int values can be assigned to floats float values can only be assigned to int explicitly int a = 1; float f = 0.5; a = f; //error a = int(f); converts f to an int

order of operations multiplication and division before addition and subtraction use parentheses to control order of operations and to clarify code

shortcuts x++, x-- add or subtract one from the variable +=, -= combines addition/subtraction with assignment x += 5 is equivalent to x =x + 5

random() random (x) returns a float between 0 and x use int() to convert result to an int int() truncates the remainder random (x, y) returns a float between x and y

Decisions values can be compared with relational operators 3 > 5 // false 3 > 2 // true

our friends the relational operators > greater than < less than > = greater than or equal to <= less than or equal to == equivalent to (don t use =)!= not equivalent to

no seriously, don t use = to compare two values. use == instead.

Conditionals if (test) { } statements if test is true, do code in brackets if test is false ignore code in brackets

?)*+&,"+ B*&2$2#!! "#$ %% &' ( #&)*

C4)+*--$"2 C5&'.&,$"2 +,-.*!!*+,-. +,-. +,-.*!!*/012. /012. /012.*!!*/012. /012. +,-.*%%*+,-. +,-. +,-.*%%*/012. +,-. /012.*%%*/012. /012. (+,-. /012. (/012.* +,-. *

Iteration make code compact repeat processes make fun things possible

For For (init; test; update) { statements }

For (init; test; update) { statements } 1. Init Statement is run 2. Test is evaluated true or false 3. If test is true, jump to step 4. If false, jump to step 6 4. Run statements within the block 5. Run the update statement

Homework write a sketch that makes a random drawing use random, variables, conditionals and relational operators use save() to save and print your three favorite versions