CSC 120 Introduction to Creative Graphical Coding, Fall 2015
|
|
- Brenda Hopkins
- 5 years ago
- Views:
Transcription
1 CSC 120 Introduction to Creative Graphical Coding, Fall 2015 Dr. Dale E. Parson, Outline in preparation for assignment 2. How to move your avatar in a function and give it X, Y, and scaling parameters. Below is my solution to assignment 1. I have highlighted in bold the portion that draws the avatar so I can show you how to move it into a function with parameters. I will place both sketches avatar and avatarfunction under S:\ComputerScience\Parson in case you want to get access to the code. 1 /************************************************************ 2 /* Author: Dr. Parson 3 /* Creation Date: 9/17/ /* Due Date: 9/26/ /* Course: CSC120 Intro. to Creative Graphical Coding 6 /* Professor Name: Dr. Parson 7 /* Assignment: 1. 8 /* Sketch name: avatar 9 /* Purpose: Animate an avatar using Processing. 10 *********************************************************/ // Modeled after int backgroundcolor = 0 ; // Wraps from 255 back to int avatarx = 0 ; // Move the avatar left-right-left in cycles. 16 int rangex = 0 ; // range X from 0 to 2*width-1 for avatarx update 17 int legx = 0 ; // How far is leg from X endpoint, range // Also use 2 * lexg offset to wiggle arms up & down (in Y coordinate); 19 // HIGHPOINTS: 20 // 1. Use % operator as outlined in handout to bounce avatar back & forth across 21 // screen using avatarx and rangex. Use legx to wiggle leg endpoints 22 // back & forth, arms up & down. 23 // 2. Use semi-transparency of grass and sky to pass through background light to dark, 24 // which also cycles smoothly from day-night-day. backgroundcolor used for both 25 // background gray scale and tree red/green mix void setup() { 28 size(750, 500); 29 background(backgroundcolor); 30 } void draw() { 33 //background(backgroundcolor); 34 //backgroundcolor = (backgroundcolor + 1) % 256 ; 35 // Make the background cyclic through light & dark, no jumps. 36 background(abs(backgroundcolor - 255)); 37 backgroundcolor = (backgroundcolor + 1) % 511 ; // PAINT BACKGROUND SCENERY.. 40 rectmode(center); 41 // Semi-transparent green grass uses the background's light-to-dark. 42 fill(0, 100, 0, 100); 43 rect(width/2, height*3/4, width, height/2); 44 // Semi-transparent blue sky uses the background's light-to-dark. 45 fill(0, 0, 100, 100); page 1
2 46 rect(width/2, height/4, width, height/2); // Create the building (library). 49 fill(108, 57, 15); 50 rect(width/2, height/4, width/2, height/3); 51 rect(width/2, height/2-35, width, height/3); 52 fill(100); 53 rect(width/2, height/2, width*2/3, height/5); 54 // Create poles leading into library, make one foreground later. 55 strokeweight(4); 56 stroke(200); 57 ellipsemode(center); 58 fill(255); 59 /* move this to foreground 60 line(width/4, height/4, width/4, height*3/4); 61 line(width*3/4, height/4, width*3/4, height*3/4); 62 arc(width/4, height/4, 50, 50, PI, 2*PI, PIE); 63 arc(width*3/4, height/4, 50, 50, PI, 2*PI, PIE); 64 */ line(width/3, height/3, width/3, height*2/3); 67 line(width*2/3, height/3, width*2/3, height*2/3); 68 arc(width/3, height/3, 40, 40, PI, 2*PI, PIE); 69 arc(width*2/3, height/3, 40, 40, PI, 2*PI, PIE); // Make the next poll be the same distance further. 72 int newx = (width/3 - width/4) + width/3 ; 73 // Do the same for its height -- shrink by same amount. 74 int newy = (height/3 - height/4) + height/3 ; 75 line(newx, newy, newx, height-newy); 76 line(width-newx, newy, width-newx, height-newy); 77 arc(newx, newy, 30, 30, PI, 2*PI, PIE); 78 arc(width-newx, newy, 30, 30, PI, 2*PI, PIE); // Draw the avatar. 81 nostroke(); 82 fill(240, 150, 150); 83 ellipse(avatarx, height/2, 50, 40); // head 84 quad(avatarx-5, height/2, avatarx+5, height/2, avatarx+10, height/2+40, avatarx-10, height/2+40); // neck 85 fill(0); // professor gown 86 ellipse(avatarx, height/2+60, 40, 80); // torso 87 stroke(0); 88 // stick arms & legs 89 strokeweight(8); 90 line(avatarx, height/2+60, avatarx-20-abs(10-legx), height/2+120); // left leg 91 line(avatarx, height/2+60, avatarx+20+abs(10-legx), height/2+120); // right leg 92 strokeweight(5); 93 line(avatarx, height/2+60, avatarx-40, height/2+20-2*abs(10-legx)); // left arm 94 line(avatarx, height/2+60, avatarx+40, height/2+20+2*abs(10-legx)); // right arm 95 strokeweight(2); 96 fill(0, 50, 255); 97 ellipse(avatarx-10, height/2-5, 10, 10); // avatar's right side of glasses 98 ellipse(avatarx+10, height/2-5, 10, 10); // avatar's right side of glasses 99 line(avatarx-5, height/2-5, avatarx+5, height/2-5); // glasses connector 100 line(avatarx-15, height/2-5, avatarx-22, height/2-8); // left earpiece page 2
3 101 line(avatarx+15, height/2-5, avatarx+22, height/2-8); // right earpiece 102 fill(0); 103 ellipse(avatarx, height/2+1, 5, 5); // nose 104 arc(avatarx, height/2+10, 20, 10, 0, PI); // mouth 105 quad(avatarx-30, height/2-15, avatarx+30, height/2-15, avatarx+15, height/2-30, avatarx-35, height/2-30); 106 // get ready for movement in next frame. 107 rangex = (rangex+1) % (width*2); 108 avatarx = width - abs(rangex - width); 109 legx = (legx+1) % 20 ; /* move this to foreground */ 112 // Create last pole leading into library. 113 strokeweight(6); 114 stroke(200); 115 ellipsemode(center); 116 fill(255); 117 line(width/4, height/4, width/4, height*3/4); 118 line(width*3/4, height/4, width*3/4, height*3/4); 119 arc(width/4, height/4, 50, 50, PI, 2*PI, PIE); 120 arc(width*3/4, height/4, 50, 50, PI, 2*PI, PIE); // fill(0, 100, 0) ; // dark green for some foreground trees 124 fill(255 - abs(backgroundcolor - 255), abs(backgroundcolor - 255), 0); 125 nostroke(); 126 triangle(0, 0, 100, 180, 0, 180); 127 triangle(0, 135, 100, 315, 0, 315); 128 triangle(0, 270, 100, 450, 0, 450); 129 fill(85, 73, 25); 130 rectmode(corner); 131 rect(0, 450, 20, height-450); // Put another tree on the right. 134 // fill(0, 100, 0) ; // dark green for some foreground trees 135 fill(255 - abs(backgroundcolor - 255), abs(backgroundcolor - 255), 0); 136 nostroke(); 137 triangle(width, 0, width-100, 180, width, 180); 138 triangle(width, 135, width-100, 315, width, 315); 139 triangle(width, 270, width-100, 450, width, 450); 140 fill(85, 73, 25); 141 rectmode(corner); 142 rect(width-20, 450, width, height-450); 143 } 144 The specific parts of my avatar do not matter for this explanation. The following points about the above bold code are important. 1) Every part of the avatar s body plots X relative to variable avatarx, which is the variable my first assignment uses to move the avatar by updating avatarx within draw(). 2) Every part of the avatar s body plots Y relative to the display height. 3) Width and height of ellipses and rectangles, and colors of fill and stroke, are just constant values. They do not use variables. page 3
4 Your solution to assignment 1 differs in details, but the basic outline above must apply to your solution 1 in order for it to work. Here is my solution to assignment 2, avatarfunction, which uses an if construct, a for loop, and a function named avatar to plot the avatar. I have highlighted all code that changed from my solution 1 so emphasize the changes. 1 /************************************************************ 2 /* Author: Dr. Parson 3 /* Creation Date: 10/4/ /* Due Date: 10/22/ /* Course: CSC120 Intro. to Creative Graphical Coding 6 /* Professor Name: Dr. Parson 7 /* Assignment: 2. 8 /* Sketch name: avatarfunction 9 /* Purpose: Animate an avatar using a function to scale & locate it. 10 *********************************************************/ // Modeled after int backgroundcolor = 0 ; // Wraps from 255 back to int avatarx = 0 ; // Move the avatar left-right-left in cycles. 16 int speedx = 4 ; // speed of motion, negative for left. 17 int legx = 0 ; // How far is leg from X endpoint, range float avscale = 2.0 ; // How much to scale avatar up or down. 19 int level = 1 ; 20 int leveldirection = 1 ; 21 // Also use 2 * lexg offset to wiggle arms up & down (in Y coordinate); 22 // HIGHPOINTS: 23 // 1. Use if and a function. 24 // 2. Use semi-transparency of grass and sky to pass through background light to dark, 25 // which also cycles smoothly from day-night-day. backgroundcolor used for both 26 // background gray scale and tree red/green mix void setup() { 29 size(750, 500); 30 background(backgroundcolor); 31 } void draw() { 34 // Make the background cyclic through light & dark, no jumps. 35 background(abs(backgroundcolor - 255)); 36 backgroundcolor = (backgroundcolor + 1) % 511 ; // PAINT BACKGROUND SCENERY.. 39 rectmode(center); 40 // Semi-transparent green grass uses the background's light-to-dark. 41 fill(0, 100, 0, 100); 42 rect(width/2, height*3/4, width, height/2); 43 // Semi-transparent blue sky uses the background's light-to-dark. 44 fill(0, 0, 100, 100); 45 rect(width/2, height/4, width, height/2); // Create the building (library). 48 fill(108, 57, 15); page 4
5 49 rect(width/2, height/4, width/2, height/3); 50 rect(width/2, height/2-35, width, height/3); 51 fill(100); 52 rect(width/2, height/2, width*2/3, height/5); if (level == 4) { 55 avatar(avatarx, height/2, legx,.25); 56 /* WILL ADD THIS LOOP LATER 57 for (int i = 0 ; i < 7 ; i++) { 58 avatar(avatarx + (i-3) * 13, height/2, legx,.25); 59 } 60 */ 61 } // This is the poll closest to the building. 64 strokeweight(4); 65 stroke(200); 66 ellipsemode(center); 67 fill(255); 68 int newx = (width/3 - width/4) + width/3 ; 69 // Do the same for its height -- shrink by same amount. 70 int newy = (height/3 - height/4) + height/3 ; 71 line(newx, newy, newx, height-newy); 72 line(width-newx, newy, width-newx, height-newy); 73 arc(newx, newy, 30, 30, PI, 2*PI, PIE); 74 arc(width-newx, newy, 30, 30, PI, 2*PI, PIE); if (level == 3) { 77 avatar(avatarx, height/2, legx,.5); 78 /* WILL ADD THIS LOOP LATER 79 for (int i = 0 ; i < 5 ; i++) { 80 avatar(avatarx + (i-2) * 25, height/2, legx,.5); 81 } 82 */ 83 } // Next pole 86 strokeweight(4); 87 stroke(200); 88 ellipsemode(center); 89 fill(255); 90 line(width/3, height/3, width/3, height*2/3); 91 line(width*2/3, height/3, width*2/3, height*2/3); 92 arc(width/3, height/3, 40, 40, PI, 2*PI, PIE); 93 arc(width*2/3, height/3, 40, 40, PI, 2*PI, PIE); if (level == 2) { 96 avatar(avatarx, height/2, legx, 1.0); 97 /* WILL ADD THIS LOOP LATER 98 for (int i = 0 ; i < 3 ; i++) { 99 avatar(avatarx + (i-1) * 50, height/2, legx, 1.0); 100 } 101 */ 102 } /* move this to foreground */ page 5
6 105 // Create last pole leading into library. 106 strokeweight(6); 107 stroke(200); 108 ellipsemode(center); 109 fill(255); 110 line(width/4, height/4, width/4, height*3/4); 111 line(width*3/4, height/4, width*3/4, height*3/4); 112 arc(width/4, height/4, 50, 50, PI, 2*PI, PIE); 113 arc(width*3/4, height/4, 50, 50, PI, 2*PI, PIE); if (level == 1) { 116 avatar(avatarx, height/2, legx, 2.0); 117 } // fill(0, 100, 0) ; // dark green for some foreground trees 120 fill(255 - abs(backgroundcolor - 255), abs(backgroundcolor - 255), 0); 121 nostroke(); 122 triangle(0, 0, 100, 180, 0, 180); 123 triangle(0, 135, 100, 315, 0, 315); 124 triangle(0, 270, 100, 450, 0, 450); 125 fill(85, 73, 25); 126 rectmode(corner); 127 rect(0, 450, 20, height-450); // Put another tree on the right. 130 // fill(0, 100, 0) ; // dark green for some foreground trees 131 fill(255 - abs(backgroundcolor - 255), abs(backgroundcolor - 255), 0); 132 nostroke(); 133 triangle(width, 0, width-100, 180, width, 180); 134 triangle(width, 135, width-100, 315, width, 315); 135 triangle(width, 270, width-100, 450, width, 450); 136 fill(85, 73, 25); 137 rectmode(corner); 138 rect(width-20, 450, width, height-450); // get ready for movement in next frame. 141 avatarx = avatarx + speedx ; 142 if (avatarx > width+70) { 143 speedx = -speedx ; 144 level = level + leveldirection ; 145 } else if (avatarx < -70) { 146 speedx = -speedx ; 147 level = level + leveldirection ; 148 } 149 if (level > 4) { 150 level = 3 ; 151 leveldirection = - leveldirection ; 152 } else if (level < 1) { 153 level = 2 ; 154 leveldirection = - leveldirection ; 155 } 156 legx = (legx+1) % 20 ; 157 } 158 page 6
7 159 void avatar(int avx, int avy, int legdist, float avscale) { 160 // Draw the avatar. 161 nostroke(); 162 fill(240, 150, 150); 163 ellipse(avx, avy, 50 * avscale, 40 * avscale); // head 164 quad(avx-5 * avscale, avy, avx+5 * avscale, avy, avx+10 * avscale, avy+40 * avscale, avx-10 * avscale, avy+40 * avscale); // neck 165 fill(0); // professor gown 166 ellipse(avx, avy+60 * avscale, 40 * avscale, 80 * avscale); // torso 167 stroke(0); 168 // stick arms & legs 169 strokeweight(8); 170 line(avx, avy+60 * avscale, avx-20 * avscale-abs(10-legdist) * avscale, avy+120 * avscale); // left leg 171 line(avx, avy+60 * avscale, avx+20 * avscale+abs(10-legdist) * avscale, avy+120 * avscale); // right leg 172 strokeweight(5); 173 line(avx, avy+60 * avscale, avx-40 * avscale, avy+20 * avscale-2*abs(10-legdist) * avscale); // left arm 174 line(avx, avy+60 * avscale, avx+40 * avscale, avy+20 * avscale+2*abs(10-legdist) * avscale); // right arm 175 strokeweight(2); 176 fill(0, 50, 255); 177 ellipse(avx-10 * avscale, avy-5 * avscale, 10 * avscale, 10 * avscale); // avatar's right side of glasses 178 ellipse(avx+10 * avscale, avy-5 * avscale, 10 * avscale, 10 * avscale); // avatar's right side of glasses 179 line(avx-5 * avscale, avy-5 * avscale, avx+5 * avscale, avy-5 * avscale); // glasses connector 180 line(avx-15 * avscale, avy-5 * avscale, avx-22 * avscale, avy-8 * avscale); // left earpiece 181 line(avx+15 * avscale, avy-5 * avscale, avx+22 * avscale, avy-8 * avscale); // right earpiece 182 fill(0); 183 ellipse(avx, avy+1 * avscale, 5 * avscale, 5 * avscale); // nose 184 arc(avx, avy+10 * avscale, 20 * avscale, 10 * avscale, 0, PI); // mouth 185 quad(avx-30 * avscale, avy-15 * avscale, avx+30 * avscale, avy-15 * avscale, avx+15 * avscale, 186 avy-30 * avscale, avx-35 * avscale, avy-30 * avscale); 187 } 188 Here are the important points to note about the changes highlighted in bold. A) I moved my avatar drawing into a function named avatar() at line 159 above. B) This function has parameters for the X location of the avatar called avx, Y called avy, the distance of the leg and arm wiggle in legdist, and a float scaling factor called avscale. I made it a float because it may be a fraction such as 0.5 for ½. C) I changed every instance of avatarx in the original code to avx, the name of the parameter. You can do this with the search-and-replace window of the Processing editor, although be careful that you do not Change all outside of this function. Parameter avx exists only inside this function. D) I changed every instance of height/2 in the original code to avy within the function, because height/2 gave the Y coordinate in the original. E) I multiplied the avscale times all of the fixed distance parameters in the original. For example, these two adjacent lines in the original: 98 ellipse(avatarx+10, height/2-5, 10, 10); // avatar's right side of glasses 99 line(avatarx-5, height/2-5, avatarx+5, height/2-5); // glasses connector became this in the above function: page 7
8 178 ellipse(avx+10 * avscale, avy-5 * avscale, 10 * avscale, 10 * avscale); // avatar's right side of glasses 179 line(avx-5 * avscale, avy-5 * avscale, avx+5 * avscale, avy-5 * avscale); // glasses connector Two important things to note are a) I did not use the avscale parameter while I was working on getting avx and avy to work, and b) when avscale is 1.0, it does not change the value from assignment 1. Expression avx-5 * 1.0 gives the same result as avatarx-5 in assignment 1. Multiplication and division have higher precedence than addition or subtraction, which means in this case that the multiplication by 1.0 happens first. However, when avscale is 0.5, it will halve the distances, and so on. The scaled distances apply to offsets from avx and avy as in this example, and they apply to width of figures such as rectangles and ellipses. F) I replaced variable legx in the original code with parameter legdist. I did not bother to scale the legdist because I wanted to see the effect. G) Now that there is a function that draws an avatar, I tested it using the line of code at line 96, which is where I had all of the avatar code in assignment avatar(avatarx, height/2, legx, 1.0); That is a function call to my new avatar function, similar to your calls to background(), stroke(), fill(), and other functions from processing s library. It passes the original values used in assignment 1 as arguments to the function, with 1.0 for avscale. I ran the program to make sure that I got exactly the same result before proceeding from here. Now I inserted four conditional calls to avatar at various places in the code, like this. These calls plot the avatar at various scales, and at different times in the sequence of plotting foreground and background scenery. Ignore the loops that are commented out for now. 54 if (level == 4) { 55 avatar(avatarx, height/2, legx,.25); 56 /* WILL ADD THIS LOOP LATER 57 for (int i = 0 ; i < 7 ; i++) { 58 avatar(avatarx + (i-3) * 13, height/2, legx,.25); 59 } 60 */ 61 } 76 if (level == 3) { 77 avatar(avatarx, height/2, legx,.5); 78 /* WILL ADD THIS LOOP LATER 79 for (int i = 0 ; i < 5 ; i++) { 80 avatar(avatarx + (i-2) * 25, height/2, legx,.5); 81 } 82 */ 83 } 95 if (level == 2) { 96 avatar(avatarx, height/2, legx, 1.0); 97 /* WILL ADD THIS LOOP LATER 98 for (int i = 0 ; i < 3 ; i++) { 99 avatar(avatarx + (i-1) * 50, height/2, legx, 1.0); 100 } page 8
9 101 */ 102 } 115 if (level == 1) { 116 avatar(avatarx, height/2, legx, 2.0); 117 } Level 2 is the original location of plotting the avatar. The function s arguments are the original values of the variables, with 1.0 for the scale, which plots at the original size. The only parameter change in the other calls is the avscale, which makes a bigger avatar at level 1 and smaller avatars at levels 3 and 4. I could have changed the first or second parameter to create offsets for avy or avy. In fact, the commented-out loops do that. We will go over them in class. H) Note these changes in variable definitions and variable updates at the top of the program and bottom of draw() respectively. 15 int avatarx = 0 ; // Move the avatar left-right-left in cycles. 16 int speedx = 4 ; // speed of motion, negative for left. 17 int legx = 0 ; // How far is leg from X endpoint, range float avscale = 2.0 ; // How much to scale avatar up or down. 19 int level = 1 ; 20 int leveldirection = 1 ; 140 // get ready for movement in next frame. 141 avatarx = avatarx + speedx ; 142 if (avatarx > width+70) { 143 speedx = -speedx ; 144 level = level + leveldirection ; 145 } else if (avatarx < -70) { 146 speedx = -speedx ; 147 level = level + leveldirection ; 148 } 149 if (level > 4) { 150 level = 3 ; 151 leveldirection = - leveldirection ; 152 } else if (level < 1) { 153 level = 2 ; 154 leveldirection = - leveldirection ; 155 } 156 legx = (legx+1) % 20 ; 157 } // THIS IS THE BOTTOM OF draw() I replaced all uses of the % modulo operator with an if statement, and I used another if statement to keep the value of level between 1 and 4 inclusive. These ifs are based on textbook examples we have already gone over. If you understand these individual steps, you will be able to extend your assignment 1 for assignment 2. Another handout explains assignment 2. We will go over my commented-out for loops in class. page 9
10 page 10
CSC 120 Introduction to Creative Graphical Coding, Fall 2017
CSC 120 Introduction to Creative Graphical Coding, Fall 2017 Dr. Dale E. Parson, Assignment 1, Implementing and testing an automated avatar in Processing. This assignment is due via D2L Assignments Assignment
More informationCSC 120 Introduction to Creative Graphical Coding, Fall 2015
CSC 120 Introduction to Creative Graphical Coding, Fall 2015 Dr. Dale E. Parson, Assignment 1, Implementing and testing an automated avatar in Processing. This assignment is due via D2L Dropbox Assignment
More informationCSC 220 Object-Oriented Multimedia Programming, Spring 2017
CSC 220 Object-Oriented Multimedia Programming, Spring 2017 Dr. Dale E. Parson, Assignment 2, Working with 3D shapes and geometric transforms. This assignment is due via D2L Dropbox Assignment 2 ShapePaint3DIntro
More informationKimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013
1. A first program // Create 200x200 canvas // Print favorite quote size(200, 200); println("it is what it is"); // Draw rectangle and a line rect(100,100,50,50); line(0,0,50,50); // Save as.pde. Can be
More informationCISC 1600, Lab 2.1: Processing
CISC 1600, Lab 2.1: Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using Sketchpad, a site for building processing sketches online using processing.js. 1.1. Go to http://cisc1600.sketchpad.cc
More informationCISC 1600, Lab 3.1: Processing
CISC 1600, Lab 3.1: Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using OpenProcessing, a site for building processing sketches online using processing.js. 1.1. Go to https://www.openprocessing.org/class/57767/
More informationKimberly Nguyen Professor Oliehoek Assignment 3. 1 A // Declare frequented variables int h = 20; void setup() { size(400, 200); smooth(); }
1 A // Declare frequented variables int w = 20; int h = 20; size(400, 200); void drawflashlight(int coloring,int i) { // Draw 8 dim flashlights for (int x = 0; x < width; x+=width/(i)) { ellipsemode(corner);
More informationIteration in Programming
Iteration in Programming for loops Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list There are three types of loop in programming: While
More informationInteraction Design A.A. 2017/2018
Corso di Laurea Magistrale in Design, Comunicazione Visiva e Multimediale - Sapienza Università di Roma Interaction Design A.A. 2017/2018 7 Conditionals in Processing Francesco Leotta, Andrea Marrella
More informationmith College Computer Science CSC103 How Computers Work Week 6 Fall 2017 Dominique Thiébaut
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
More informationmith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut
mith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu Important Review Does the animation leave a trace? Are the moving objects move without a
More informationProcessing Assignment Write- Ups
Processing Assignment Write- Ups Exercise 1-1 Processing is not an elaborate series of points like connect the dots or is it? Can t be cause I got it all wrong when I mapped out each and every point that
More information1 Getting started with Processing
cis3.5, spring 2009, lab II.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For
More informationIf 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.
Conditionals 75 Reversing the Polarity of a Number When we want to reverse the polarity of a number, we mean that we want a positive number to become negative and a negative number to become positive.
More informationINTRODUCTION TO PROCESSING. Alark Joshi, Amit Jain, Jyh-haw Yeh and Tim Andersen
INTRODUCTION TO PROCESSING Alark Joshi, Amit Jain, Jyh-haw Yeh and Tim Andersen What is Processing? Processing is a programming language designed to make programming easier Developers were frustrated with
More information1 Getting started with Processing
cisc3665, fall 2011, lab I.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For
More informationRecall that creating or declaring a variable can be done as follows:
Lesson 2: & Conditionals Recall that creating or declaring a variable can be done as follows:! float radius = 20;! int counter = 5;! string name = Mr. Nickel ;! boolean ispressed = true;! char grade =
More informationCS110 Introduction to Computing Fall 2016 Practice Exam 1 -- Solutions
CS110 Introduction to Computing Fall 2016 Practice Exam 1 -- Solutions The exam will be closed-note and closed-book; please consider this fact before using your notes on this practice version. Please see
More information+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.
+ Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create
More informationAnimatron Tutorial. Ronald Bourret
Animatron Tutorial Ronald Bourret http://www.rpbourret.com Table of Contents License... 2 Lesson 1: Getting Started... 3 1.1 Creating an Animatron account... 3 1.2 Animatron screen... 3 Lesson 2: Drawing...
More informationSolution Notes. COMP 151: Terms Test
Family Name:.............................. Other Names:............................. ID Number:............................... Signature.................................. Solution Notes COMP 151: Terms
More informationCS 101 Functions. Lecture 15
CS 101 Functions Lecture 15 1 Key Processing language features so-far Basic color/shapes drawing Variables For-loops If-statements 2 Functions In the next few days, we ll be talking about Functions A Function
More informationCISC 1600 Lecture 3.1 Introduction to Processing
CISC 1600 Lecture 3.1 Introduction to Processing Topics: Example sketches Drawing functions in Processing Colors in Processing General Processing syntax Processing is for sketching Designed to allow artists
More informationClass #1. introduction, functions, variables, conditionals
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
More informationWe will start our journey into Processing with creating static images using commands available in Processing:
Processing Notes Chapter 1: Starting Out We will start our journey into Processing with creating static images using commands available in Processing: rect( ) line ( ) ellipse() triangle() NOTE: to find
More informationUsing Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics
Using Methods Methods that handle events Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Caveat The term function is used in Processing e.g. line(),
More informationA B C D CS105 03a Interaction
Interaction Function Definition Events Built-in Variables CS105 03a Interaction 1 Which image is drawn by this code? strokeweight(10); stroke(0, 255, 0); // green line(99, 0, 0, 99); stroke(200, 0, 200);
More informationIntroduction to Processing. Sally Kong
Introduction to Processing Sally Kong - Open Source Platform - Geared toward creating visual, interactive media - Created by Ben Fry and Casey Reas Basic Setup void setup() { size(800, 600); background(255);
More informationTransform 1: Translate, Matrices
Transform 1: Translate, Matrices This unit introduces coordinate system transformations and explains how to control their scope. Syntax introduced: translate(), pushmatrix(), popmatrix() The coordinate
More informationInteraction Design A.A. 2017/2018
Corso di Laurea Magistrale in Design, Comunicazione Visiva e Multimediale - Sapienza Università di Roma Interaction Design A.A. 2017/2018 5 Basics of Processing Francesco Leotta, Andrea Marrella Last update
More informationDesign Programming DECO2011
Design Programming DECO2011 Rob Saunders web: http://www.arch.usyd.edu.au/~rob e-mail: rob@arch.usyd.edu.au office: Room 274, Wilkinson Building Data, Variables and Flow Control What is a Variable? Computers
More informationReal Time Data Plotting
Real Time Data Plotting Introduction This lesson will show how to write a program plot data on a X-Y graph. On the Arduino, write a program to sample a sensor and print the voltage to the Serial interface.
More informationOld 257 Exam #2s for Practice
Old Exam #2s 257/757 Exploring Programming with Graphics Page 1 Old 257 Exam #2s for Practice Exams will be taken on Thursday March 27 in the cluster. You will have the entire class time to do the exam.
More informationEvaluating Logical Expressions
Review Hue-Saturation-Brightness vs. Red-Green-Blue color Decimal, Hex, Binary numbers and colors Variables and Data Types Other "things," including Strings and Images Operators: Mathematical, Relational
More information5.1. Examples: Going beyond Sequence
Chapter 5. Selection In Chapter 1 we saw that algorithms deploy sequence, selection and repetition statements in combination to specify computations. Since that time, however, the computations that we
More informationRepetition is the reality and the seriousness of life. Soren Kierkegaard
6 Loops Loops 81 Repetition is the reality and the seriousness of life. Soren Kierkegaard What s the key to comedy? Repetition. What s the key to comedy? Repetition. Anonymous In this chapter: The concept
More informationVocabulary: Looking For Pythagoras
Vocabulary: Looking For Pythagoras Concept Finding areas of squares and other figures by subdividing or enclosing: These strategies for finding areas were developed in Covering and Surrounding. Students
More informationCISC 1600, Lab 2.2: Interactivity in Processing
CISC 1600, Lab 2.2: Interactivity in Processing Prof Michael Mandel 1 Getting set up For this lab, we will again be using Sketchpad, a site for building processing sketches online using processing.js.
More informationVariables One More (but not the last) Time with feeling
1 One More (but not the last) Time with feeling All variables have the following in common: a name a type ( int, float, ) a value an owner We can describe variables in terms of: who owns them ( Processing
More informationWhat is a variable? a named location in the computer s memory. mousex mousey. width height. fontcolor. username
What is a variable? a named location in the computer s memory mousex mousey width height fontcolor username Variables store/remember values can be changed must be declared to store a particular kind of
More informationCS110 Introduction to Computing Fall 2016 Practice Exam 1
CS110 Introduction to Computing Fall 2016 Practice Exam 1 The exam will be closed-note and closed-book; please consider this fact before using your notes on this practice version. Please see the abbreviated
More informationConditional Events. Mouse events and Operators. Dr. Siobhán Drohan Mairead Meagher. Produced by:
Conditional Events Mouse events and Operators Produced by: Dr. Siobhán Drohan Mairead Meagher Department of Computing and Mathematics http://www.wit.ie/ Topics list Mouse Events Recap: Arithmetic Operators
More informationCISC 1600, Lab 3.2: Interactivity in Processing
CISC 1600, Lab 3.2: Interactivity in Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using OpenProcessing, a site for building processing sketches online using processing.js. 1.1.
More informationPick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1
Conditionals Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary CS105 04 Conditionals 1 Pick a number CS105 04 Conditionals 2 Boolean Expressions An expression that
More informationUsing Methods. More on writing methods. Dr. Siobhán Drohan Mairead Meagher. Produced by: Department of Computing and Mathematics
Using Methods More on writing methods Produced by: Dr. Siobhán Drohan Mairead Meagher Department of Computing and Mathematics http://www.wit.ie/ Topics list Method example: Eyes Method example: X s Overloading
More informationProcessing & Arduino in Tandem. Creating Your Own Digital Art Tools
Processing & Arduino in Tandem Creating Your Own Digital Art Tools Week 2 - Making your own drawing tool Using Processing to build a basic application Segment 1 - A Basic Drawing Program Change window
More informationCISC 1600, Lab 2.3: Processing animation, objects, and arrays
CISC 1600, Lab 2.3: Processing animation, objects, and arrays Prof Michael Mandel 1 Getting set up For this lab, we will again be using Sketchpad. sketchpad.cc in your browser and log in. Go to http://cisc1600.
More informationAn Introduction to Processing
An Introduction to Processing Creating static drawings Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list Coordinate System in Computing.
More informationPerfect square numbers are formed when we multiply a number (factor) by itself, or square a number. 9 is a perfect square, and 3 is it s factor.
Math Unit 1: Square Roots and Surface Area. Review from Grade 8: Perfect Squares What is a perfect square? Perfect square numbers are formed when we multiply a number (factor) by itself, or square a number.
More informationKhan Academy JavaScript Study Guide
Khan Academy JavaScript Study Guide Contents 1. Canvas graphics commands with processing.js 2. Coloring 3. Variables data types, assignments, increments 4. Animation with draw loop 5. Math expressions
More informationCS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help
CS 2110 Fall 2012 Homework 4 Paint Program Due: Wednesday, 12 November, 11:59PM In this assignment, you will write parts of a simple paint program. Some of the functionality you will implement is: 1. Freehand
More informationUniversity of Cincinnati. P5.JS: Getting Started. p5.js
p5.js P5.JS: Getting Started Matthew Wizinsky University of Cincinnati School of Design HTML + CSS + P5.js File Handling & Management Environment Canvas Coordinates Syntax Drawing Variables Mouse Position
More informationEXAMINATIONS 2017 TRIMESTER 2
EXAMINATIONS 2017 TRIMESTER 2 CGRA 151 INTRODUCTION TO COMPUTER GRAPHICS Time Allowed: TWO HOURS CLOSED BOOK Permitted materials: Silent non-programmable calculators or silent programmable calculators
More information2D Shapes. Creative Coding & Generative Art in Processing 2 Ira Greenberg, Dianna Xu, Deepak Kumar
2D Shapes Creative Coding & Generative Art in Processing 2 Ira Greenberg, Dianna Xu, Deepak Kumar Did you do this? Read Chapter 2 (pages 33-50) Read and do the Coordinate Systems & Shapes and Color tutorials
More informationTo 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".
The most popular lesson I teach is editing photographs. Everyone wants to put his or her brother's head on a monkey or something similar. This is also a lesson about "emphasis". You can cause more individuals
More informationEXAMINATIONS 2016 TRIMESTER 2
EXAMINATIONS 2016 TRIMESTER 2 CGRA 151 INTRODUCTION TO COMPUTER GRAPHICS Time Allowed: TWO HOURS CLOSED BOOK Permitted materials: Silent non-programmable calculators or silent programmable calculators
More informationInteraction Design A.A. 2017/2018
Corso di Laurea Magistrale in Design, Comunicazione Visiva e Multimediale - Sapienza Università di Roma Interaction Design A.A. 2017/2018 8 Loops and Arrays in Processing Francesco Leotta, Andrea Marrella
More informationTHE JAVASCRIPT ARTIST 15/10/2016
THE JAVASCRIPT ARTIST 15/10/2016 Objectives Learn how to program with JavaScript in a fun way! Understand the basic blocks of what makes a program. Make you confident to explore more complex features of
More informationQuestion. What is a fraction? Answer: A topic that scares many of our students
Question What is a fraction? Answer: A topic that scares many of our students More seriously: Please write down your definition of a fraction. Then briefly discuss with a neighbor. FRACTIONS are numbers
More information4th Grade Math Scope & Sequence-June 2017
4th Grade Math Scope & Sequence-June 2017 Topic Strand Concept State Standard 1: Generalize Place Value Understanding * Read and write numbers in expanded form, with number names. * Recognize the relationship
More informationCMPSCI 119 LAB #2 Greebles / Anime Eyes Professor William T. Verts
CMPSCI 119 LAB #2 Greebles / Anime Eyes Professor William T. Verts The goal of this Python programming assignment is to write your own code inside a provided program framework, with some new graphical
More informationMATH 021 UNIT 2 HOMEWORK ASSIGNMENTS
MATH 021 UNIT 2 HOMEWORK ASSIGNMENTS General Instructions You will notice that most of the homework assignments for a section have more than one part. Usually, the part (A) questions ask for explanations,
More informationLearning to use the drawing tools
Create a blank slide This module was developed for Office 2000 and 2001, but although there are cosmetic changes in the appearance of some of the tools, the basic functionality is the same in Powerpoint
More information7. r = r = r = r = r = 2 5
Exercise a: I. Write the equation in standard form of each circle with its center at the origin and the given radius.. r = 4. r = 6 3. r = 7 r = 5 5. r = 6. r = 6 7. r = 0.3 8. r =.5 9. r = 4 0. r = 3.
More informationGuided Problem Solving
-1 Guided Problem Solving GPS Student Page 57, Exercises 1 1: Match each rule with the correct translation. A. (x, y) (x, y 1 ) I. P(, 1) P (3, ) B. (x, y) (x 1 3, y) II. Q(3, 0) Q (3, ) C. (x, y) (x 1,
More informationPhotogram. Programmable Photoshop Language Language Reference Manual. ( ), Group Leader. (
Photogram Programmable Photoshop Language Language Reference Manual Ohan Oda Neesha Subramaniam Richard Ng Seikwon Kim ( oo2116@columbia.edu ), Group Leader ( ns2295@columbia.edu ) ( rjn2003@columbia.edu
More informationGRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing
BRIDGES TO COMPUTING General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. This work is licensed under the Creative Commons Attribution-ShareAlike
More informationThe Processing language. Arduino and Processing.
IAT267 Introduc/on to Technological Systems Lecture 8 The Processing language. Arduino and Processing. 1 Course Project All teams submibed very interes/ng proposals One requirement for the project is to
More informationName: Dr. Fritz Wilhelm Lab 1, Presentation of lab reports Page # 1 of 7 5/17/2012 Physics 120 Section: ####
Name: Dr. Fritz Wilhelm Lab 1, Presentation of lab reports Page # 1 of 7 Lab partners: Lab#1 Presentation of lab reports The first thing we do is to create page headers. In Word 2007 do the following:
More informationPreparation: Get to know the Java coordinate system. 3. How is the background color of the window specified? Copy the exact code:
Lab 9 Name: Checked: Objectives: Introduction to graphics and JavaFX. Preparation: Get to know the Java coordinate system Download Snowman.java. Compile and run it to see the image it produces. 1. Note
More informationAnimatron Tutorial. Ronald Bourret
Animatron Tutorial Ronald Bourret http://www.rpbourret.com Table of Contents License... 2 Lesson 1: Getting Started... 3 1.1 Create an Animatron Account... 3 1.2 Animatron Screen... 3 Lesson 2: Drawing...
More informationNumber. Number. Number. Number
Order of operations: Brackets Give the order in which operations should be carried out. Indices Divide Multiply Add 1 Subtract 1 What are the first 10 square numbers? The first 10 square numbers are: 1,
More informationWatch the following for more announcements
Review "plain text file" loadstrings() split() splittokens() selectinput() println(), float(), int(), can take an array argument, will return an array easy way to convert an array of Strings to an array
More informationGuide to WB Annotations
Guide to WB Annotations 04 May 2016 Annotations are a powerful new feature added to Workbench v1.2.0 (Released May 2016) for placing text and symbols within wb_view tabs and windows. They enable generation
More informationGIMP WEB 2.0 ICONS. GIMP is all about IT (Images and Text) OPEN GIMP
GIMP WEB 2.0 ICONS Web 2.0 Banners: Download E-Book WEB 2.0 ICONS: DOWNLOAD E-BOOK OPEN GIMP GIMP is all about IT (Images and Text) Step 1: To begin a new GIMP project, from the Menu Bar, select File New.
More informationGetting Started in Java CIS 110
Getting Started in Java CIS 110 2 Your First Program Program name 3 Your First Program The 4 li es aside fro the System.out li e are o sidered the Scaffolding of the program. Section 1.1 4 Your First Program
More informationFunctions. Functions. nofill(); point(20, 30); float angle = map(i, 0, 10, -2, 2); parameters return values
Functions parameters return values 06 Functions 1 Functions Code that is packaged so it can be run by name Often has parameters to change how the function works (but not always) Often performs some computation
More informationEP486 Microcontroller Applications
EP486 Microcontroller Applications Topic 2 Processing Department of Engineering Physics University of Gaziantep Sep 2013 Sayfa 1 Processing is a programming language, development environment, and online
More informationThis unit introduces the basics of trigonometry and how to utilize it for generating form.
Math 3: Trigonometry This unit introduces the basics of trigonometry and how to utilize it for generating form. Syntax introduced: PI, QUARTER_PI, HALF_PI, TWO_PI, radians(), degrees() sin(), cos(), arc()
More information[ the academy_of_code] Senior Beginners
[ the academy_of_code] Senior Beginners 1 Drawing Circles First step open Processing Open Processing by clicking on the Processing icon (that s the white P on the blue background your teacher will tell
More informationMathematical Practices
Middletown Public Schools Mathematics Unit Planning Organizer Subject Mathematics -Number and Operations - Fractions Grade 4 Unit 4 Comparing Fractions and Understanding Decimal Notation Duration 0 Instructional
More informationGraphical User Interfaces
Graphical User Interfaces CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Outline Pixels & bits & colors JavaFX Introduction
More informationNotes from the Boards Set # 5 Page
1 Yes, this stuff is on the exam. Know it well. Read this before class and bring your questions to class. Starting today, we can no longer write our code as a list of function calls and variable declarations
More informationTo specify the dimensions of the drawing canvas use the size statement: ! size( 300, 400 );
Study Guide We have examined three main topics: drawing static pictures, drawing simple moving pictures, and manipulating images. The Final Exam will be concerned with each of these three topics. Each
More informationCPSC Fall L01 Final Exam
CPSC 601.36 - Fall 2009 - L01 Final Exam Copyright Jeffrey Boyd 2009 December 12, 2009 Time: 120 minutes General instructions: 1. This exam is open-book. You may use any reference material you require,
More informationAddition Properties. Properties something you cannot disprove always true. *You must memorize these properties!
Addition Properties Properties something you cannot disprove always true. *You must memorize these properties! 1) Commutative property of addition changing the order of addends will not change the sum
More informationAdobe Flash CS4 Part 4: Interactivity
CALIFORNIA STATE UNIVERSITY, LOS ANGELES INFORMATION TECHNOLOGY SERVICES Adobe Flash CS4 Part 4: Interactivity Fall 2010, Version 1.0 Table of Contents Introduction... 2 Downloading the Data Files... 2
More information(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
(Inter)Ac*ve Scripts Crea+ve Coding & Genera+ve Art in Processing 2 Ira Greenberg, Dianna Xu, Deepak Kumar Slides revised by Michael Goldwasser Sta*c Program Structure // Create and set canvas size(width,
More informationCourse Outlines. Elementary Mathematics (Grades K-5) Kids and Numbers (Recommended for K-1 students)
Course Outlines Elementary Mathematics (Grades K-5) Kids and Numbers (Recommended for K-1 students) Shapes and Patterns. Grouping objects by similar properties. Identifying simple figures within a complex
More informationTopics for section today. Homework 10 functions for loops and loading fonts
Topics for section today Homework 10 functions for loops and loading fonts Assignment 10 Sudoku Board Draw the Sudoku board in Processing using for-loops and functions Assignment 10 Sudoku Board Draw the
More informationSummer Packet 7 th into 8 th grade. Name. Integer Operations = 2. (-7)(6)(-4) = = = = 6.
Integer Operations Name Adding Integers If the signs are the same, add the numbers and keep the sign. 7 + 9 = 16 - + -6 = -8 If the signs are different, find the difference between the numbers and keep
More informationLecture 7. Processing Development Environment (or PDE)
Lecture 7 Processing Development Environment (or PDE) Processing Class Overview What is Processing? Installation and Intro. Serial Comm. from Arduino to Processing Drawing a dot & controlling position
More informationGraphical User Interfaces
Graphical User Interfaces CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: http://www.csc.villanova.edu/~map/1051/
More informationA Step-by-step guide to creating a Professional PowerPoint Presentation
Quick introduction to Microsoft PowerPoint A Step-by-step guide to creating a Professional PowerPoint Presentation Created by Cruse Control creative services Tel +44 (0) 1923 842 295 training@crusecontrol.com
More informationPrime Time (Factors and Multiples)
CONFIDENCE LEVEL: Prime Time Knowledge Map for 6 th Grade Math Prime Time (Factors and Multiples). A factor is a whole numbers that is multiplied by another whole number to get a product. (Ex: x 5 = ;
More informationWorking with Transformations on the Coordinate Plane
Working with Transformations on the Coordinate Plane Movies create the illusion of movement by showing us 24 images per second. When the human eye processes 24 images per second it is interpreted in our
More informationNature of Code. Patrick Dwyer Fall 2005 Week 4 - September 27 th
(1 of 7) Nature of Code Patrick Dwyer Fall 2005 Week 4 - September 27 th Trigonometry Trigonometry is the study and utilization of the relationships between the sides and angles of triangles. We ll be
More information3.3 Division of Fractions and of Mixed Numbers
CCBC Math 0 Division of Fractions and of Mixed Numbers Section.. Division of Fractions and of Mixed Numbers Introduction: http://youtu.be/fsdtivjjq What does it mean to divide? The basic division questions
More information1. Complete these exercises to practice creating user functions in small sketches.
Lab 6 Due: Fri, Nov 4, 9 AM Consult the Standard Lab Instructions on LEARN for explanations of Lab Days ( D1, D2, D3 ), the Processing Language and IDE, and Saving and Submitting. Rules: Do not use the
More informationDrawing a Circle. 78 Chapter 5. geometry.pyde. def setup(): size(600,600) def draw(): ellipse(200,100,20,20) Listing 5-1: Drawing a circle
5 Transforming Shapes with Geometry In the teahouse one day Nasrudin announced he was selling his house. When the other patrons asked him to describe it, he brought out a brick. It s just a collection
More information