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

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

CISC 1600, Lab 2.1: Processing

CISC 1600, Lab 3.1: Processing

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

Kimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013

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

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

The Processing language

CISC 1600 Lecture 3.1 Introduction to Processing

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

CMPT-166: Sample Midterm

Interaction Design A.A. 2017/2018

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

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

Interaction Design A.A. 2017/2018

mith College Computer Science Week 10 CSC111 Spring 2015 Dominique Thiébaut

A B C D CS105 03a Interaction

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

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

Basic Computer Programming (Processing)

1 Getting started with Processing

Interaction Design A.A. 2017/2018

CS110 Introduction to Computing Fall 2016 Practice Exam 1

The Processing language. Arduino and Processing.

Class #1. introduction, functions, variables, conditionals

CSE120 Wi18 Final Review

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

Processing Assignment Write- Ups

Class Notes CN19 Class PImage Page

Introduction to Processing. Sally Kong

Sten-SLATE ESP. Graphical Interface

Design Programming DECO2011

5.1. Examples: Going beyond Sequence

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

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

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

Solution Notes. COMP 151: Terms Test

CISC 1600, Lab 2.2: Interactivity in Processing

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

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

Iteration in Programming

CST112 Looping Statements Page 1

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

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

CISC 1600, Lab 3.2: Interactivity in Processing

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

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

All program statements you write should be syntactically correct. Partial credit is not guaranteed with incorrect use of syntax.

Question 1 (10 points) Write the correct answer in each of the following: a) Write a Processing command to create a canvas of 400x300 pixels:

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

CSC231 C Tutorial Fall 2018 Introduction to C

Name CMPS 5J Final March 17, 2010 This is a closed notes, closed book exam. Each problem is worth 1 point unless indicated otherwise.

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

Exploring Processing

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

[ the academy_of_code] Senior Beginners

Lecture 7. Processing Development Environment (or PDE)

An Introduction to Processing

Introduction to Processing

Paint Tutorial (Project #14a)

EXAMINATIONS 2016 TRIMESTER 2

Khan Academy JavaScript Study Guide

Module 01 Processing Recap. CS 106 Winter 2018

mith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut

CSC 120 Introduction to Creative Graphical Coding, Fall 2015

Watch the following for more announcements

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

Bits and Bytes. How do computers compute?

if / if else statements

Final Exam Winter 2013

Module 01 Processing Recap

Processing Presentation by Ben Leduc-Mills

Expressions and Variables

1. Create a map of the layer and attribute that needs to be queried

THE JAVASCRIPT ARTIST 15/10/2016

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

SFPL Reference Manual

PyGame Unit ?

CISC 1600 Lecture 2.2 Interactivity&animation in Processing

Expression Design Lab Exercises

mith College Computer Science Lecture Notes CSC111 Week 7 Spring 2018 Dominique Thiébaut

If the ball goes off either the right or left edge, turn the ball around. If x is greater than width or if x is less than zero, reverse speed.

The Junior Woodchuck Manuel of Processing Programming for Android Devices

Variables and Control Structures. CS 110 Eric Eaton

CISC 1600 Lecture 2.2 Interactivity&animation in Processing

Module 05 User Interfaces. CS 106 Winter 2018

EP486 Microcontroller Applications

CST112 Variables Page 1

Graphics Overview ECE2893. Lecture 19. ECE2893 Graphics Overview Spring / 15

mith College Computer Science CSC231 C Tutorials Fall 2017 Introduction to C Dominique Thiébaut

Transform 1: Translate, Matrices

We Create Identity Programming. STUDENT MANUAL v1.1

mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut

Old 257 Exam #2s for Practice

CSC 220 Object-Oriented Multimedia Programming, Spring 2017

Graphics: Legacy Library

Introduction to CS Dealing with tables in Word Jacek Wiślicki, Laurent Babout,

CMPT-166: Sample Final Exam Answer Key

Chapter 2 Exercise Solutions

CPSC Fall L01 Final Exam

Transcription:

mith College Computer Science CSC103 How Computers Work Week 6 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu

Ben Fry on Processing... http://www.youtube.com/watch?&v=z-g-cwdnudu

An Example Mouse 2D Example http://processing.org/examples/mouse2d.html Computer Science Dominique Thiebaut

Another Example Sophisticated Coding http://wearechopchop.com/%e2%80%9cunnamed-soundsculpture%e2%80%9d/

Documentation

Examples

Tutorials

Dan Shiffman http://hello.processing.org/

The Sketch Integrated Development Environment (IDE) Run/Stop Name of sketch Programming area (editor) Program

The Sketch

The Sketch

The Sketch

Program Organization // circles // D. Thiebaut // displays circles following the // mouse pointer. void setup() { size( 500, 500 ); smooth(); } void draw() { ellipse( mousex, mousey, 80, 80 ); } Comments Functions setup(): once draw(): many times/ sec

Program Organization Run // circles // D. Thiebaut void setup() { size( 500, 500 ); smooth(); } void draw() { ellipse( mousex, mousey, 80, 80 ); } Comments Functions setup(): once draw(): many times/ sec

Program Organization Run // circles // D. Thiebaut void setup() { size( 500, 500 ); smooth(); } void draw() { ellipse( mousex, mousey, 80, 80 ); } Comments Functions setup(): once draw(): many times/ sec

Program Organization Run // circles // D. Thiebaut void setup() { size( 500, 500 ); smooth(); } void draw() { ellipse( mousex, mousey, 80, 80 ); } Comments Functions setup(): once draw(): many times/ sec

Program Organization Run // circles // D. Thiebaut void setup() { size( 500, 500 ); smooth(); } void draw() { ellipse( mousex, mousey, 80, 80 ); } Comments Functions setup(): once draw(): many times/ sec

Program Organization // circles // D. Thiebaut void setup() { size( 500, 500 ); smooth(); } void draw() { ellipse( mousex, mousey, 80, 80 ); } Comments Functions setup(): once draw(): many times/ sec Animation Loop

Understanding mousex & mousey

Understanding size(w,h)

Understanding background()

Exercise replace the circles by squares

Exercise Mix circles and squares. Circles only move horizontally with the mouse.

Exercise Circles move horizontally with the mouse, and squares move vertically.

Using Random Numbers

The random() function https://processing.org/reference/random_.html

Printing random()

Exercise Replace mousex and mousey by calls to random(500)

Understanding Colors

Understanding Colors

Understanding Colors

Understanding Colors

Understanding Colors Pixel

Understanding Colors { 23 Pixel 13 19

Understanding Colors { 23 red Pixel 13 green 19 blue

RGB System Each pixel corresponds to 3 numbers 1st number = shade of red in the color of the pixel 2nd number = shade of green in the color of the pixel 3rd number = shade of blue in the color of the pixel Red-Green-Blue = RGB Each shade is represented by 8 bits

1 bit 0 1 2 bits 00 01 10 11 3 bits 000 001 010 011 100 101 110 111 4 bits 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 RGB System 8 bits 0000000 0000001 0000010 0000011 1111100 1111101 1111110 1111111

Color Selector

Good Reference on Color Dan Shiffman's page: https://processing.org/tutorials/color/

https://www.reddit.com/r/dataisbeautiful/comments/7584no/3d_rgb_scatterplots_of_colours_used_in_famous/

Example Make the circles blue, and the squares red.

Exercise Emulate this graphic output

Exercise Emulate this graphic output Note that some ellipses are flat, others are tall and skinny

Exercise Emulate this graphic output Note that all ellipses are perfect circles

Variables

Variables They contain data Real numbers, integer numbers, characters Variables have a name Names always start with a letter or an underscore, and can contain letters or digits: x, y, i, alpha, r2d2, c3po, x1, pi

Example

Example float x = 3.5; float y = 5.2; float sum; sum = x + y; println( "sum = " + sum );

Types float int String (see https://processing.org/reference/string.html) boolean

// define geometry of rectangle float w = random(100, 300); float h = random(100, 300); float x = random( 500 ); float y = random( 500 ); Example // draw a transparent grey version of it // at 5,5, offset from mouse cursor nostroke(); fill( 200, 200, 200, 100 ); rect( x+5, y+5, w, h ); // draw a randomly colored rectangle at mouse // cursor float red = random( 255 ); float green = random( 255 ); float blue = random( 255 ); fill ( red, green, blue ); rect( x, y, w, h );

Loops (See https://processing.org/reference/for.html)

Example 1 for ( int i=0; i <= 10; i++ ) { } println( i );

Example 1 for ( int i=0; i <= 10; i++ ) { } println( i );

Example 2 int sum = 0; for ( int counter=0; counter <= 10; counter++ ) { sum = sum + counter; } println( "sum = ", sum )

Example 3 void draw() { fill( 200, 100, 0 ); } for ( int x=50; x<500; x = x + 100 ) { ellipse( x, 100, 40, 40 ); }

Example 4 void draw() { fill( 200, 100, 0 ); for ( int x=50; x<500; x = x + 100 ) { } ellipse( x, 100, 40, 40 ); }

Example 5 void draw() { fill( 200, 100, 0 ); for ( int x=50; x<500; x = x + 100 ) { for ( int y=50; y<500; y = y + 100 ) { aellipse( x, y, 40, 40 ); } } }

Testing Quantities