Computation as an Expressive Computation as an Expressive MediumMediumMediumMediumLab Lab 22: : Kindergarten Cubbies,Kindergarten Cubbies,Back to the Future and LegoBack to the Future and LegoManiaManiaManiaManiaJoshua CuneoJoshua CuneoJoshua CuneoJoshua CuneoThis WeekThis WeekThis WeekThis Week Assignment 1 Assignment 1 ArraysArraysArraysArrays TimeTimeCtiCtiCastingCasting Reading codeReading code Project 1Project 1Assignment Assignment 11AA11--0101: Draw three lines.: Draw three lines.AA11--0202: Draw five lines.: Draw five lines.AA11--0303: Draw three ellipses: Draw three ellipsesAA110303: Draw three ellipses.: Draw three ellipses.AA11--0404: Control the position of two lines with one variable.: Control the position of two lines with one variable.AA11--0505: Control the position and size of two lines with two variables.: Control the position and size of two lines with two variables.AA11--0606: Control the properties of two shapes with two variables.: Control the properties of two shapes with two variables.AA11--0707: Create a simple, regular pattern with six lines.: Create a simple, regular pattern with six lines.AA110707: Create a simple, regular pattern with six lines.: Create a simple, regular pattern with six lines.AA11--0808: Program your pattern from Assignment : Program your pattern from Assignment 11--07 07 using while().using while().AA11--0909: Draw a layered form with two new loops.: Draw a layered form with two new loops.AA11--1010: Redo Assignment : Redo Assignment 11--05 05 using mouseX and mouseY as the variables.using mouseX and mouseY as the variables.AA11--1111: Draw two visual elements that each move in relation to the mouse in a : Draw two visual elements that each move in relation to the mouse in a different way.different way.AA11--1212: Draw three visual elements that each move in relation to the mouse in a : Draw three visual elements that each move in relation to the mouse in a different way.different way.AA11--1313: Move a visual element across the screen. When it disappears off the edge, : Move a visual element across the screen. When it disappears off the edge, move it back into the frame.move it back into the frame.AA11--1414: Draw a visual element that moves in relation to the mouse but with a : Draw a visual element that moves in relation to the mouse but with a different relation when the mouse is pressed.different relation when the mouse is pressed.AA11--1515: Using if and else, make the mouse perform different actions when in different : Using if and else, make the mouse perform different actions when in different parts of the window.parts of the window.AA11--1616: Develop a kinetic image which responds to the mouse.: Develop a kinetic image which responds to the mouse.A Few RemindersA Few RemindersA Few RemindersA Few RemindersWe know you are not programmersWe know you are not programmersWe know you are not programmersWe know you are not programmers Don’t get too caught up in syntaxDon’t get too caught up in syntaxThe API is your friendThe API is your friend Have fun with your assignmentsHave fun with your assignmentsygygBrianBrianJoshuaJoshuaClass formatClass formatLab formatLab formatClass formatClass format Class gradesClass gradesReading/presentationsReading/presentationsLab formatLab format AssignmentAssignment gradesgradesProgrammingProgrammingReading/presentationsReading/presentations Due dates Due dates Programming Programming assignmentsassignmentsIl fIl f I love my TAI love my TAI love my professorI love my professorAasAasArraysArraysArraysArraysArraysArraysClark Bruce Diana PetercubbiescubbiesArraysArraysArraysArraysClark Bruce Diana Petercubbies[Bruce]cubbies[Bruce]ArraysArraysArraysArraysint[] numbers = new int[3];ORint[] numbers = {90, 150, 30};0 1 2 numbers[0] = 90;numbers[1] = 150;numbers[2] = 30;90 150 300 1 2ArraysArraysyyClark Bruce Diana PeterClark Bruce Diana PeterArraysArraysArraysArraysClarkBruceDianaPeterClarkBruceDianaPeter*Some exceptions applyWhy Do We Care?Why Do We Care?Why Do We Care?Why Do We Care? ConciseConciseEfficientEfficientEfficientEfficient LoopLoop--ableableBubblesortBubblesortvoid bubblesort(int[] input) {int temp1int temp = -1;for(int i = 0; i < input.length; i++) {f(itj0j<itlth1j++)for(int j = 0; j < input.length -1; j++){if(input[j] > input[j+1]) {{temp = input[j+1];input[j+1] = input[j];input[j] = temp;} //end if} //end for(j) } //end for(i) }Processing APIProcessing APIProcessing APIProcessing APIaappend()ppend()shorten()shorten()aappend()ppend() arrayCopy()arrayCopy()cconcat()oncat()shorten()shorten() sort()sort()splice()splice()cconcat()oncat() eexpand()xpand()splice()splice() subset()subset() rreverse()everse()ArraysArraysArraysArrays//Retrieving array valuesint a = numbers[0] + numbers[1]; // Sets variable a to 240 int b = numbers[1] + numbers[2]; // Sets variable b to 180 //Changing array size at runtimeString[] sa1 = { "OH ", "NY ", "CA "}; String[] sa2 = append(sa1, "MA "); println(sa2); // Prints OH, NY, CA, MATimeTimeint hour()int hour()int hour()int hour() int minute()int minute() int second()int second() int day()int day()y()y() int month()int month()int year()int year()int year()int year() long millis()long millis()TimeTimeTimeTimeCastingCastingCastingCastingint x = 3;int y = x/2; //y = 1?????int x = 3;float y = (float)x/2; //y = 1.5Reading CodeReading Codevoid setup() { size(400,400); } Reading CodeReading Codeint ellipseSize = 1; void draw() { smooth(); background(0); stroke(234,98,71); strokeWeight(10); fill(0); ellipse(200,200,ellipseSize,ellipseSize); if (( X >0)&&( X<400)&&( Y>0)&&( Y<200))if ((mouseX > 0) && (mouseX < 400) && (mouseY > 0) && (mouseY < 200)) { ellipseSize = ellipseSize + 1; } else {{ ellipseSize = ellipseSize - 1; } if (ellipseSize < 1) {{ ellipseSize = 1; } if (ellipseSize > 400) {{ ellipseSize = 400; } }Reading CodeReading Codevoid setup() { size(400,400); } Reading CodeReading Codeint ellipseSize = 1; void draw() { smooth(); background(0); stroke(234,98,71); strokeWeight(10); fill(0); ellipse(200,200,ellipseSize,ellipseSize); if (( X > 0) && ( X < 400) && ( Y > 0) && ( Y < 200))if ((mouseX > 0) && (mouseX < 400) && (mouseY > 0) && (mouseY < 200)) { ellipseSize = ellipseSize + 1;
View Full Document