Chapter 5, Conditionals Brief Notes

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

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.
Variables Conditionals Boolean Expressions Conditional Statements How a program produces different results based on varying circumstances if, else if,
Game with US Beginner Tutorial. Welcome!! Who I am What is Processing? Basic Coding Input Methods Images Classes Arrays.
Code Elements and Processing Coordinate System. Code elements: pages Comments: are documentation notes that are ignored by the computer but are.
Emerging Platform#5: Processing 2 B. Ramamurthy 6/13/2014B. Ramamurthy, CS6511.
Chapter 2 - The First Program: Little Crab
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
PROCESSING Animation. Objectives Be able to create Processing animations Be able to create interactive Processing programs.
Review Blocks of code {.. A bunch of ‘statements’; } Structured programming Learning Processing: Slides by Don Smith 1.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Continuous February 16, Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?
Keyboard and Events. What about the keyboard? Keyboard inputs can be used in many ways---not just for text The boolean variable keyPressed is true if.
Processing Lecture.2 Mouse and Keyboard
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
Variables and Arithmetic. From last class More drawing functions: strokeWeight(n); // higher the n value broader the stroke fill(k) ; // single parameter.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02b: Tutorial for Programming in Processing Jarek Rossignac.
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.
Variables Art &Technology, 3rd Semester Aalborg University Programming David Meredith
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
Processing TYWu. Where can I download? 2.0b9 Windows 32-bit.
Often being different. Control flow By default Java (and therefore Processing) executes lines of a program one after the other –Doesn’t matter what happened.
Continuous. Flow of Control Programs can broadly be classified as being –Procedural Programs are executed once in the order specified by the code varied.
B. RAMAMURTHY Processing and Programming cse
Test Review. General Info. All tests will be comprehensive. You will be tested more on your understanding of code as opposed to your ability to write.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
Processing Variables. Variables Processing gives us several variables to play with These variables are always being updated and you can assume they have.
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.
Task 1 and Task 2. Variables in Java Programs Variables start with lower case letter Variables are descriptive of what they store Variables are one word.
Some of Chap 17.
Emerging Platform#1: Processing 3
p5.js mouse, keyboard and if’s
Chapter 14, Translate & Rotate
“Processing” easy coding Jens Dalsgaard Nielsen
Lesson One: The Beginning Chapter 1: Pixels Learning Processing Daniel Shiffman Presentation by Donald W. Smith Graphics from
20 minutes maximum exhibits
Chapter 7 Functions.
Computation as an Expressive Medium
The Little Crab Scenario
Code Elements and Processing Coordinate System
For Net Art Lecture 2 J Parker
Exam1 Review CSE113 B.Ramamurthy 11/29/2018 B.Ramamurthy.
Chapter 10 Algorithms.
Mouse Inputs in Processing
Chapter 10 Algorithms.
More programming with "Processing"
Code Elements and Processing Coordinate System
Pages:51-59 Section: Control1 : decisions
Lecture 6: Conditionals AP Computer Science Principles
IAT 265 Lecture 2: Java Loops, Arrays Processing setup, draw, mouse Shapes Transformations, Push/Pop.
Just a question for Mac users:
CS2011 Introduction to Programming I Selections (I)
Exam1 Review CSE113 B.Ramamurthy 4/17/2019 B.Ramamurthy.
LCC 6310 Computation as an Expressive Medium
Loops & Nested Loops CSE 120 Winter 2019
Chapter 10 Algorithms.
Chapter 4, Variables Brief Notes
Trigonometry & Random March 2, 2010.
How About Some PI? Trigonometry Feb 18,2009.
Pages:51-59 Section: Control1 : decisions
Variables and Operators
Chapter 13, Math A few Examples.
Spell your name using word art from above
Presentation transcript:

Chapter 5, Conditionals Brief Notes

Relational Operators for Booleans Boolean Expressions Boolean – An expression that evaluates to either true or false. Relational Operators for Booleans > < = >= <= == != Notice this one

Syntax for Conditionals A single condition: Multiple conditions: if(Boolean test) { //code to run if true } if(Boolean test1) { //code to run if true }else if (Boolean test2) { }else if (Boolean test3) { else { //code to run none of //the above is true } Two conditions: if(Boolean test) { //code to run if true } else { //code to run if false }

Algorithm for Exercise 5-1 If 90 and above, grade is A If 80 and above, grade is B If 70 and above, grade is C If 60 and above, grade is D otherwise, grade is F

Constrain functions limits a value r = constrain(r, 0, 255) This is used on pages 72-73 instead of two if statements.

Both conditions must be met in order to draw rectangle void draw() { background(0); if (mouseX > width/2 && mouseY > height/2) { fill(#ffff00); rect( 10,10,10,10); } Draw a different shape if mouse is pressed. If it’s not pressed an ellipse is drawn. void draw() { rectMode(CENTER); background(120); if(!mousePressed) { ellipse(50,50,50,50); }else { rect(50,50,50,50); }

Controlling buttons We will examine a couple of sketched from pages 77-83. They are examples of controlling buttons by hovering, pressing, or clicking.

These are possibilities for this exercise. Exercise 5-9, pg. 86 These are possibilities for this exercise. //exercise 5_9 possibilities int x= 0; int speed= 3; //sped it up a bit int y = 0; float r = 255; float g = 0; float size = 75; void setup() { size(200,200); } void draw() { background(0); noStroke(); y = y + speed; x = x + speed; // to keep colors r&g between 0 & 255 g = g + 1; r = r - 1; if (g >255 ) { g = 0; if (r < 0 ) { r =255; //if it reaches either edge, turn around by changing polarity if ((x > width) || (x < 0) || (y>height) || (y < 0) ){ speed = speed * -1; //size change using some crazy association if (x < width/2) { size = size - 2; }else{ size = size + 2; //display circle //stroke(#00aa00); fill(r, g, 0 ); ellipse(x, y, size, size);