Basic Input and Output

Similar documents
Basic Input and Output

Basic Input and Output

Basic Input and Output

Functions in Processing

A B C D CS105 03a Interaction

Instructor: Teaching Assistants: Justin Hsia Anupam Gupta, Cheng Ni, Eugene Oh, Sam Wolfson, Sophie Tian, Teagan Horkan

Exploring Processing

CISC 1600, Lab 2.2: Interactivity in Processing

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.

CISC 1600, Lab 3.2: Interactivity in Processing

CISC 1600 Lecture 2.2 Interactivity&animation in Processing

1 Getting started with Processing

Instructor: Teaching Assistants: Justin Hsia Anupam Gupta, Cheng Ni, Eugene Oh, Sam Wolfson, Sophie Tian, Teagan Horkan

Anupam Gupta, Braydon Hall, Eugene Oh, Savanna Yee. Steve Jobs custom Apple I and other historic machines are on display at Seattle museum

Watch the following for more announcements

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

Functions in Processing

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

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

Introduction to Processing. Sally Kong

Computer Graphics. Interaction

Recursion I. CSE 120 Spring Anupam Gupta, Braydon Hall, Eugene Oh, Savanna Yee

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

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

1 Getting started with Processing

Kimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013

CST112 Variables Page 1

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

Interaction Design A.A. 2017/2018

[ the academy_of_code] Senior Beginners

Introduction to Processing

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

CISC 1600 Lecture 2.2 Interactivity&animation in Processing

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

CISC 1600, Lab 3.1: Processing

void mouseclicked() { // Called when the mouse is pressed and released // at the same mouse position }

This Week Assignment 1 Arrays Time Casting Reading code Project 1

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

The Processing language

CISC 1600, Lab 2.3: Processing animation, objects, and arrays

CISC 1600, Lab 2.1: Processing

PROGRAMMING. We create identity

CSE115 Lab 4 Fall 2016

Interaction Design A.A. 2017/2018

CSE120 Wi18 Final Review

GRAPHICS PROGRAMMING. LAB #3 Starting a Simple Vector Animation

Bits and Bytes. How do computers compute?

CISC 1600 Lecture 3.1 Introduction to Processing

CS 106 Winter Lab 03: Input and Output

Class #1. introduction, functions, variables, conditionals

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

Sten-SLATE ESP. Graphical Interface

Art, Randomness, and Functions

Processing. Data Visualization Programming Language. By Rutvi Joshi. Processing Visualization Language- By Rutvi Joshi

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

Functions in Processing

Navigation Apps With Millions of Downloads Exposed as Just Google Maps With Bonus Ads

for(int i = 0; i < numbers.length; i++) {

(Inter)Ac*ve Scripts. Sta*c Program Structure 1/26/15. Crea+ve Coding & Genera+ve Art in Processing 2 Ira Greenberg, Dianna Xu, Deepak Kumar

Welcome to Lab! Feel free to get started until we start talking! The lab document is located on the course website:

HAPPY HOLIDAYS PHOTO BORDER

Standards/ Strands Essential Questions Skills Assessment. What are the strengths and weaknesses of Processing as a programming language?

CS110 Introduction to Computing Fall 2016 Practice Exam 1

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

Getting Started in Java CIS 110

CpSc 1111 Lab 4 Formatting and Flow Control

CS 150 Lab 3 Arithmetic and the Debugger. Lab 3.0 We are going to begin using the Visual Studio 2017 debugger to aid with debugging programs.

Lab 2. CSE 3, Summer 2010 In this lab you will learn about file structures and advanced features of Microsoft Word.

AP Computer Science Principles Python Programming Using Processing

Spring CS Homework 3 p. 1. CS Homework 3

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

To get a copy of this image you right click on the image with your mouse and you will get a menu. Scroll down the menu and select "Save Image As".

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

SCRATCH MODULE 3: NUMBER CONVERSIONS

CS 051 Homework Laboratory #2

Some of the Choices. If you want to work on your own PC with a C++ compiler, rather than being logged in remotely to the PSU systems

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

This assignment was revised from the original PDF released to revise/add Parts D and E.

CS 106A, Lecture 14 Events and Instance Variables

Lesson 1 Excel Tutorial Learning how to use Microsoft Excel 2010 page 1

Welcome to Lab! You do not need to keep the same partner from last lab. We will come around checking your prelabs after we introduce the lab

The Processing language. Arduino and Processing.

Recall that creating or declaring a variable can be done as follows:

SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC

Review: C Strings. A string in C is just an array of characters. Lecture #4 C Strings, Arrays, & Malloc

CMSC427 Interac/ve programs in Processing: Polyline editor

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

GOALS [HTDP/2e Chapters 1 through 3.5]

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.

Khan Academy JavaScript Study Guide

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

EXAMINATIONS 2016 TRIMESTER 2

INTRODUCTION TO PROCESSING. Alark Joshi, Amit Jain, Jyh-haw Yeh and Tim Andersen

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?

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

PowerPoint Quick-Start. Table of Contents. How to Get Help. Information Technology

Module 05 User Interfaces. CS 106 Winter 2018

Final Exam Winter 2013

Instructions for Crossword Assignment CS130

Transcription:

Basic Input and Output CSE 120 Spring 2017 Instructor: Justin Hsia Teaching Assistants: Anupam Gupta, Braydon Hall, Eugene Oh, Savanna Yee

Administrivia Assignments: Animal Functions due today (4/12) Reading Check 3 due tomorrow before lab (4/13) Jumping Monster due Saturday (4/15) Big Idea this week: Algorithms 2

Outline Other Useful Processing Tools User Input and Output Mouse (input) Keyboard (input) Text (output) 3

System Variables Special variables that hold values related to the state of the program, often related to user input You don t need to declare these variables These variables will update automatically as the program runs Colored pink/magenta ish in the Processing environment We ve used some of these already: mousex, mousey, width, height We ll see more today 4

Transparency/Opacity You can add a 4 th argument to a color! This also applies to the fill() and stroke() functions This argument also takes an integer between 0 255 0 is fully transparent (invisible) 255 is fully opaque (the default) 5

Custom Shapes Define vertices between beginshape() and endshape() If planning to reuse, best to create in a separate function 6

Drawing and Frames Control and track how frequently draw() runs Each time draw() runs, it is called a new frame framerate() changes the desired number of frame updates there are per second So larger argument is faster Default is framerate(60) System variable framecount returns the number of frames since the start of the program Starts at 0 in setup() 7

Drawing and Frames Control and track how frequently draw() runs Each time draw() runs, it is called a new frame noloop() stops draw() from being continuously executed Can restart using loop() 8

Outline Other Useful Processing Tricks User Input and Output * Mouse Keyboard Text * We will look at a subset of the available Processing commands. For a full list, see the Processing Reference. 9

The Mouse System variables: mousex x coordinate of mouse in current frame mousey y coordinate of mouse in current frame pmousex x coordinate of mouse in previous frame pmousey y coordinate of mouse in previous frame mousepressed is a button currently being pressed? Built in functions: mousepressed() called very time a button is pressed mousereleased() called every time a button is released 10

Example: Path Drawing Last lecture we wrote a dot drawing program We can additionally use pmousex and pmousey to create a path drawing program 11

Example: Frame Dots Slow down to 1 frame per second and have a new dot appear on each frame Number of dots on screen will equal current frame count Reminder: framerate(), framecount Calculate position using division and modulus Control the animation with the mouse Pause while mouse is pressed Reminder: loop(), noloop() 12

Hovering Over a Rectangle (x,y) w h if(mousex >= x) if(mousex <= x + w) 13

Hovering Over a Rectangle (x,y) w h if(mousey >= y) if(mousey <= y + h) 14

Hovering Over a Rectangle (x,y) w h if( (mousex >= x) && (mousex <= x + w) && (mousey >= y) && (mousey <= y + h) ) 15

Hovering Over a Rectangle 16

The Keyboard System variables: key stores the ASCII value of the last key press keycode stores codes for non ASCII keys (e.g. UP, LEFT) keypressed is any key currently being pressed? Built in functions: keypressed() called every time a key is pressed New datatype: char Stores a single character (really just a number) Should be surrounded by single quotes e.g. char letter = a ; 17

Example: Keyboard Dots 18

Text Output println(yourtext); Prints yourtext to the console, which is the black area below your Processing code Useful for debugging, particularly your portfolio text(yourtext, x, y); Prints yourtext on the drawing canvas, starting with the bottom left corner at coordinate (x,y) Change the size of your text using textsize(size); yourtext should be between double quotes We will talk about the datatype String later 19

Example: Displaying Typed Keys 20

Example: Moving a Rectangle Reminder: arrow keys (UP, DOWN, LEFT, RIGHT) are coded keys 21

Example: Moving a Rectangle 22

Looking Forward Next week is the Creativity Assignment In pairs, you will be asked to create and submit TWO Processing projects of your choice The point is to use the tools available to you to make something fun and creative! Planning document due Tuesday (4/18) Actual programs due next, next Monday (4/24) Portfolio Update 1 is due Tuesday (4/18) Building a Robot, Logo Design, Lego Family, Animal Functions, Jumping Monster Ask your TAs for assistance! 23