CSC 220 Object-Oriented Multimedia Programming, Spring 2017

Size: px
Start display at page:

Download "CSC 220 Object-Oriented Multimedia Programming, Spring 2017"

Transcription

1 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 by 11:59 PM on Sunday March 5. I have added a weekend to compensate for the snow day. 10% penalty for each day it is late. When using Processing on the Kutztown campus Windows computers, make sure to start out every time by setting your Processing Preferences -> Sketchbook Location to U:\Processing. The U:\ drive is a networked drive that will save your work and make it accessible across campus. If you save it to your desktop or the lab PC you are using, you will lose your work when you log out. You must save it to the U:\ drive. If you do not have a folder called Processing under U:\, you must create one using the Windows Explorer. Processing Preferences is under the File menu on Windows. If you will be downloading Processing 3.X and running it using an off-campus computer (do not use version 2.X for assignments), you can copy your project sketch named ShapePaint3DIntro to a flash drive on one machine, and then copy it from the flash drive to another Processing sketch folder. PREPARATORY STEP A: Open your assignment 1 ShapePaint2DMinimal sketch and SAVE AS ShapePaint3DIntro. You must remove most of my code to get a clean start. After replacing my name with yours at the top of the sketch, replace the global variables and the following global functions with these definitions: page 1

2 /************************************************************ /* Author: Dr. Parson (Replace with STUDENT name.) /* Due Date: Sunday 11:59 PM, 10% penalty per day late /* Course: CSC120 Intro. to Creative Graphical Coding /* Professor Name: Dr. Parson /* Assignment: 2. /* Sketch name: ShapePaint3DIntro (Introductory version of 3D). *********************************************************/ ShapeObjectTemplate [] visible = new ShapeObjectTemplate[10]; // Initially visible[0] == null, etc. int visiblecount = 0 ; // incr on '+', decr on '-', clear on '_' // visible.length gives the full length of the array (the number // of elements it can hold). Use visiblecount to record how many // non-null object references are in the array. boolean tomove = true ; // toggle to false to avoid moving the objects, toggle on 'm' boolean isortho = false ; // false for perspective(), true for ortho(), change in 'o' vs 'p' void setup() { void draw() { The above is the entire starting point for the top of the sketch. Below are detailed instructions on what to do in each global function. We will not be using any Java HashMaps in this assignment. The 10-element array visible declared above is the only collection of objects. Also hollow out the keypressed() function near the bottom of the sketch in preparation: void keypressed() { PREPARATORY STEP B: Delete all code for class b and class c from assignment 1. KEEP interface ShapeObjectTemplate and class a implements ShapeObjectTemplate in your sketch, but eliminate method getboundingbox() from both of them, since we won t be using it. KEEP class a s other methods unchanged for now. You will be changing class a to use 3D shapes and transforms, but you also need to rewrite setup(), draw(), and keypressed(). Keeping 2D class a unchanged for now allows you to test those global method changes. You will have to change these lines of code in move(): if (x < -domewidthheight/2 x > domewidthheight/2) { speedx = -speedx ; to this: if (x < -width/2 x > width/2) { speedx = -speedx ; if (x < -width/2) { x = (-width/2) + 1 ; // Bring it back into range. else { x = width/2-1 ; // Bring it back into range page 2

3 Make similar changes to the if (y < -domewidthheight/2 y > domewidthheight/2) block of code, using height instead of width. Also, in shuffle() replace domewidthheight with width for x and height for y. This code will work with a rectangular display, and we need not need to tailor it for a planetarium. At this point your sketch should compile correctly, although with empty setup(), draw(), and keypressed() global functions, it does not do anything. There are only 4 global variables above. You may add more later if you like. I didn t need more. Here is what they provide: ShapeObjectTemplate [] visible = new ShapeObjectTemplate[10]; // Initially visible[0] == null, etc. int visiblecount = 0 ; // incr on '+', decr on '-', clear on '_' // visible.length gives the full length of the array (the number // of elements it can hold). Use visiblecount to record how many // non-null object references are in the array. Array visible can hold up to 10 object references for object classes derived from interface ShapeObjectTemplate. Initially, array elements visible[0] through visible[visible.length-1] contain the null value (lower case), where visible.length-1 == 9 for this array. Note that unlike C++, a Java array stores its length in its.length field; an array is an object that includes a.length field. Variable visiblecount records the number of consecutive elements in visible that are non-null, starting at visible[0]. At this point there are no object references in the array. boolean tomove = true ; // toggle to false to avoid moving the objects, toggle on 'm' boolean isortho = false ; // false for perspective(), true for ortho(), change in 'o' vs 'p' Variable tomove is a boolean that is set to default true when a loop within draw() is to call move() after display() for each non-null object. My draw() code for assignment 1 uses variable tomove in this way. Variable isortho is a boolean that indicates perspective() projection when false, and ortho() (orthographic) projection when true. We will go over these two forms of projection in class. REQUIREMENT 1 (5%): This is the only step in my setup() function. Add more if you like. Set the size() of the window, using P3D as the third argument so that we can use 3D shapes. The window does not need to be a square. An alternative would be fullscreen(p3d). Do not use both. REQUIREMENT 2 (15%): Start the draw() function with this code: void draw() { if (isortho) { ortho(); // Use orthographic projection else { perspective(); // Use perspective projection. spheredetail(15); // Limit detail on spheres to reduce CPU load. Here are the instructions for the rest of draw(): page 3

4 Set a background() color, a contrasting stroke() color, and a strokeweight() greater than 0. Draw a set of widely spaced lines across the display. You may draw horizontal or vertical lines in a for loop or while loop. My screen dump below shows widely spaced diagonal lines. You may draw diagonal lines if you want, but vertical or horizontal are fine. Use only 2D coordinates for the line endpoints, allowing the z coordinate to default to 0. Complete the draw() function with this code: pushmatrix(); translate(width/2, height/2, 0); LOOP to display and optionally move objects in array visible. popmatrix(); For the above LOOP you can use a for loop or while loop with C++-like syntax, iterating from visible[0] through visible[visiblecount-1]. Those elements should be!= null if your code updates visiblecount correctly, although, feel free to check visible[i]!= null before using any array element visible[i]. Within the LOOP, call the display() method for any non-null element. Immediately after calling display(), call move() on that same object if and only if global variable tomove is true. My assignment 1 code has similar calls to move(). An example 3D screen dump for my solution. Note my lines for REQUIREMENT 2. page 4

5 REQUIREMENT 3 (20%): Rewrite the keypressed() function from scratch as follows: A key == '+' constructs a new a() object and adds it to array visible, adjusting visiblecount appropriately. If visiblecount == visible.length, then there are no null elements the array is full. In that case, use random() to randomly select one of the array elements 0 through visible.length-1, and store the reference to the new a() in that location, replacing the previous reference, without changing visiblecount. A key == '-' assigns null into the topmost element of visible and decrements visiblecount by 1. A key == '_' (underline) resets all visible elements to null and visiblecount to 0. A key == 'm' (lower case m) toggles the value in global variable tomove between true and false. See key == 'M' (uppercase M) in assignment 1 s keypressed(). A key == 'o' (the lower case letter) sets global variable isortho to true. A key == 'p' sets global variable isortho to false. A key == '~' (tilde) loops through array visible and calls shuffle() on every non-null element. A key == 's' calls library function saveframe("screen3d-######.png") to take a screen shot of your sketch s window and store it in a file in your sketch. Make sure to clean these out with a file explorer to recover space; DO NOT accidentally remove your.pde source file by mistake. Document these key commands in a comment block near the top of your sketch. At this point your sketch should work correctly with your previous 2D implementation of class a. Make sure to test all key commands thoroughly. REQUIREMENT 4 (20%): Rewrite method display() in class a to create some kind of stick figure or other mobile entity with multiple body parts, where most of the body parts are 3D shapes. The Processing reference lists the following 3D library functions: 3D Primitives: box(), sphere(), and spheredetail(). It is also possible to create custom 3D PShape obejcts via createshape() with 3-dimensional vertices or groups of 2D objects in a 3D arrangement. I will show examples in class for the adventurous. Creating and using a custom 3D PShape earns 5% bonus points, but is not required. If you create such a PShape, tell me in a comment near the top. I used only 3D sphere() in my solution illustrated on the previous page, except for the mouth, which is a 2D arc. Here are my data fields for class a. You can add others, and eliminate any you decide not to use. You do need to keep x, y, z, speedx, speedy, and speedz. The shape needs to move in all 3 dimensions. class a implements ShapeObjectTemplate { // 3D shapes for assignment 2 float x ; float y ; float z ; float speedx ; float speedy ; float speedz ; float rotatex, rotatey, rotatez ; // degrees page 5

6 float rotatexspeed, rotateyspeed, rotatezspeed ; // in degrees int red ; int green ; int blue ; a() { shuffle(); Class a s display() function must start with the lines of code: void display() { pushmatrix(); translate(x, y, z); and end with this matching line: popmatrix(); As in assignment 1, the opening pushmatrix() saves the incoming coordinate transforms (with location 0,0 at the center of the window), and the closing popmatrix() restores them. Then, for each body part, do the following steps: a. pushmatrix() b. translate in 3D to the center of the body part, relative to the center of the body. The center of my stick figure s body on the previous page is the center of its head. c. scale if you need to grow or shrink in one or more of the 3D dimensions. d. rotate the body part if you wish, using rotatex, rotatey, and/or rotatez. You may also need an additional translate or other transform for exact positioning. e. Display the sphere(), box(), 2D shape, or PShape. f. popmatrix() For example, here is my code for the torso that connects to the head of my stick figure: // TORSO: pushmatrix(); translate(0,width/5,0); scale(.5, 2.0,.5); fill((red+51)%256, (green+71)%256, (blue+91)%256); sphere(width/10); popmatrix(); My code builds my figure facing forward and standing right-side-up. I will add the code requirements to make the entire figure rotate in a step below. The translate for the TORSO places it centered below the HEAD (x and z offsets of 0), with a Y displacement of width/5; you can hard code numbers here if you like; they do not need to be a function of width or height. I found satisfactory values through trial and error. The scale() call with 3 distinct scale factors for X, Y, and Z elongates the sphere into an ellipsoid page 6

7 TORSO. Note that the TORSO is elongated in the vertical direction (scale == 2.0), and shrunk in the X and Z directions (scale ==.5). Use a scale factor of 1.0 for any dimension that you do not wish to change. Please look at the TORSO in the illustration. I used similar steps for the other body parts. Each LEG required a 3D rotate and an additional translate to slide the LEG into position. Also, I added the two EYEs, the NOSE, and the MOUTH within the scope of the HEAD s pushmatrix()-popmatrix() delimiters. Each of those has its own nested pushmatrix()- popmatrix(), translating its location relative to the center of the HEAD. I used nostroke() for the NOSE and 2D MOUTH. Feel free to experiment. Test your initial stick figure by running and adding objects to the display via the + key. REQUIREMENT 5 (5%): Add one or two of rotatex, rotatey, and/or rotatez for the entire figure, immediately after the initial translate within display(). Do not use all three, because it becomes too hard to see what is going on. REQUIREMENT 6 (20%): Rewrite the move() function to update the location and other fields inside class a, similar to assignment 1, but now in 3D. I kept x within the range width/2 TO width/2, y within the range height/2 TO height/2, and z within the range TO 100. Use some trial & error for the z limits, noting that a positive z comes toward the viewer, and a negative z goes away. Also, you MUST move the figure towards location (mousex, mousey, 0) when the mousepressed library variable is true. Here is my initial code within move() that achieves this effect; feel free to use it: void move() { if (mousepressed) { float msx = mousex-width/2 ; float msy = mousey-height/2 ; x = ((msx)+99.0*x) / 100.0; y = ((msy)+99.0*y) / 100.0; z = z / 2.0 ; else { x = x + speedx ; y = y + speedy ; z = z + speedz ; The reason for subtracting width/2 from mousex and height/2 for mousey is because mousex and mousey are in screen coordinates, with 0,0 at the upper left. The subtraction adjusts for 0,0 at the center of the display. The multiplication of the current location by 99.0, and then division by 100.0, makes movement towards the mouse location occur slowly. NOTE that while my move() is very random, your can have a highly organized move() method if you like, for example, walking in only one x, y or z direction at a time, and changing direction periodically. REQUIREMENT 7 (10%): Rewrite the shuffle() function to randomize the location and other fields inside class a, similar to assignment 1, but now in 3D. Use limits similar to those for REQUIREMENT 6. REQUIREMENT 8 (5%): Use one of rotatex, rotatey, or rotatez that you did NOT use in REQUIREMENT 5 to rotate a body part within the display() method. For example, when tomove is false in my solution, the head continues to rotate about the Y axis because I added a rotatey call within the HEAD s pushmatrix()-popmatrix() block of code in display(). page 7

CSC 120 Introduction to Creative Graphical Coding, Fall 2017

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 information

CSC 120 Introduction to Creative Graphical Coding, Fall 2015

CSC 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 information

GRAPHICS PROGRAMMING. LAB #3 Starting a Simple Vector Animation

GRAPHICS PROGRAMMING. LAB #3 Starting a Simple Vector Animation GRAPHICS PROGRAMMING LAB #3 Starting a Simple Vector Animation Introduction: In previous classes we have talked about the difference between vector and bitmap images and vector and bitmap animations. In

More information

CSC 220 Object Oriented Multimedia Programming, Fall 2018

CSC 220 Object Oriented Multimedia Programming, Fall 2018 CSC 220 Object Oriented Multimedia Programming, Fall 2018 Dr. Dale E. Parson, Assignment 3, text menu on a remote-control Android, mostly array handling. This assignment is due via D2L Assignment Assignment

More information

CSC 120 Introduction to Creative Graphical Coding, Fall 2015

CSC 120 Introduction to Creative Graphical Coding, Fall 2015 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.

More information

1 Getting started with Processing

1 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 information

CISC 1600, Lab 2.2: Interactivity in Processing

CISC 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 information

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:

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: 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: size(400, 300); b) After the above command is carried out,

More information

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

Pick 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 information

CISC 1600, Lab 3.2: Interactivity in Processing

CISC 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 information

Interaction Design A.A. 2017/2018

Interaction 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 information

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

+ 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 information

Transform 1: Translate, Matrices

Transform 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 information

CMSC427 Transformations II: Viewing. Credit: some slides from Dr. Zwicker

CMSC427 Transformations II: Viewing. Credit: some slides from Dr. Zwicker CMSC427 Transformations II: Viewing Credit: some slides from Dr. Zwicker What next? GIVEN THE TOOLS OF The standard rigid and affine transformations Their representation with matrices and homogeneous coordinates

More information

Kimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013

Kimberly 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 information

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

Recall 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 information

CISC 1600, Lab 2.1: Processing

CISC 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 information

CISC 1600 Lecture 3.1 Introduction to Processing

CISC 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 information

1 Getting started with Processing

1 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 information

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

All program statements you write should be syntactically correct. Partial credit is not guaranteed with incorrect use of syntax. With Solutions in Red CS110 Introduction to Computing Fall 2012 Section 2 Exam 1 This is an open notes exam. Computers are not permitted. Your work on this exam must be your own. Answer all questions in

More information

CISC 1600, Lab 3.1: Processing

CISC 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 information

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

The way I feel about music is that there is no right and wrong. Only true and false. Fiona Apple. true false false 5 Conditionals Conditionals 59 That language is an instrument of human reason, and not merely a medium for the expression of thought, is a truth generally admitted. George Boole The way I feel about music

More information

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

Variables. location where in memory is the information stored type what sort of information is stored in that memory Variables Processing, like many programming languages, uses variables to store information Variables are stored in computer memory with certain attributes location where in memory is the information stored

More information

mith 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 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 information

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

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca COMP 1010- Summer 2015 (A01) Jim (James) Young young@cs.umanitoba.ca jimyoung.ca Don t use == for floats!! Floating point numbers are approximations. How they are stored inside the computer means that

More information

CS116X Midterm Review Winter 2015

CS116X Midterm Review Winter 2015 CS116X Midterm Review Winter 2015 This review will most likely not cover everything that could possibly be on the exam. The following is intended to help you study but remember that you may be tested on

More information

Class #1. introduction, functions, variables, conditionals

Class #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 information

Watch the following for more announcements

Watch 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 information

Notes from the Boards Set # 5 Page

Notes 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 information

CISC 1600 Lecture 2.2 Interactivity&animation in Processing

CISC 1600 Lecture 2.2 Interactivity&animation in Processing CISC 1600 Lecture 2.2 Interactivity&animation in Processing Topics: Interactivity: keyboard and mouse variables Interactivity: keyboard and mouse listeners Animation: vector graphics Animation: bitmap

More information

CS 101 Functions. Lecture 15

CS 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 information

CSE120 Wi18 Final Review

CSE120 Wi18 Final Review CSE120 Wi18 Final Review Practice Question Solutions 1. True or false? Looping is necessary for complex programs. Briefly explain. False. Many loops can be explicitly written out as individual statements

More information

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

What can we do with Processing? Let s check. Natural Language and Dialogue Systems Lab Guest Image. Remember how colors work. MIDTERM REVIEW: THURSDAY I KNOW WHAT I WANT TO REVIEW. BUT ALSO I WOULD LIKE YOU TO TELL ME WHAT YOU MOST NEED TO GO OVER FOR MIDTERM. BY EMAIL AFTER TODAY S CLASS. What can we do with Processing? Let

More information

CISC 1600 Lecture 2.2 Interactivity&animation in Processing

CISC 1600 Lecture 2.2 Interactivity&animation in Processing CISC 1600 Lecture 2.2 Interactivity&animation in Processing Topics: Interactivity: keyboard and mouse variables Interactivity: keyboard and mouse listeners Animation: vector graphics Animation: bitmap

More information

mith 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 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 information

[ the academy_of_code] Senior Beginners

[ 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 information

Using Flash Animation Basics

Using Flash Animation Basics Using Flash Contents Using Flash... 1 Animation Basics... 1 Exercise 1. Creating a Symbol... 2 Exercise 2. Working with Layers... 4 Exercise 3. Using the Timeline... 6 Exercise 4. Previewing an animation...

More information

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

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca COMP 1010- Summer 2015 (A01) Jim (James) Young young@cs.umanitoba.ca jimyoung.ca order of operations with the explicit cast! int integervariable = (int)0.5*3.0; Casts happen first! the cast converts the

More information

Iteration in Programming

Iteration 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 information

Basic Computer Programming (Processing)

Basic Computer Programming (Processing) Contents 1. Basic Concepts (Page 2) 2. Processing (Page 2) 3. Statements and Comments (Page 6) 4. Variables (Page 7) 5. Setup and Draw (Page 8) 6. Data Types (Page 9) 7. Mouse Function (Page 10) 8. Keyboard

More information

if / if else statements

if / if else statements if / if else statements December 1 2 3 4 5 Go over if notes and samples 8 9 10 11 12 Conditionals Quiz Conditionals TEST 15 16 17 18 19 1 7:30 8:21 2 8:27 9:18 3 9:24 10:14 1 CLASS 7:30 8:18 1 FINAL 8:24

More information

What 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 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 information

Evaluating Logical Expressions

Evaluating 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 information

Old 257 Exam #2s for Practice

Old 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 information

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

1. 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 information

CMPT-166: Sample Midterm

CMPT-166: Sample Midterm CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 1 of 11 CMPT-166: Sample Midterm Last name exactly as it appears on your student card First name exactly as it appears on your student card Student Number

More information

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

Loops. Variable Scope Remapping Nested Loops. Donald Judd. CS Loops 1. CS Loops 2 Loops Variable Scope Remapping Nested Loops CS105 05 Loops 1 Donald Judd CS105 05 Loops 2 judd while (expression) { statements CS105 05 Loops 3 Four Loop Questions 1. What do I want to repeat? - a rect

More information

COMP : Practical 8 ActionScript II: The If statement and Variables

COMP : Practical 8 ActionScript II: The If statement and Variables COMP126-2006: Practical 8 ActionScript II: The If statement and Variables The goal of this practical is to introduce the ActionScript if statement and variables. If statements allow us to write scripts

More information

Variables and Control Structures. CS 110 Eric Eaton

Variables and Control Structures. CS 110 Eric Eaton Variables and Control Structures CS 110 Eric Eaton Review Random numbers mousex, mousey setup() & draw() framerate(), loop(), noloop() Mouse and Keyboard interaccon Arcs, curves, bézier curves, custom

More information

CST112 Variables Page 1

CST112 Variables Page 1 CST112 Variables Page 1 1 3 4 5 6 7 8 Processing: Variables, Declarations and Types CST112 The Integer Types A whole positive or negative number with no decimal positions May include a sign, e.g. 10, 125,

More information

Instructions for Crossword Assignment CS130

Instructions for Crossword Assignment CS130 Instructions for Crossword Assignment CS130 Purposes: Implement a keyboard interface. 1. The program you will build is meant to assist a person in preparing a crossword puzzle for publication. You have

More information

Honors Computer Science Python Mr. Clausen Program 7A, 7B

Honors Computer Science Python Mr. Clausen Program 7A, 7B Honors Computer Science Python Mr. Clausen Program 7A, 7B PROGRAM 7A Turtle Graphics Animation (100 points) Here is the overview of the program. Use functions to draw a minimum of two background scenes.

More information

Practice Written Examination, Fall 2016 Roger B. Dannenberg, instructor

Practice Written Examination, Fall 2016 Roger B. Dannenberg, instructor 15-104 Practice Written Examination, Fall 2016 Roger B. Dannenberg, instructor Possibly useful function signatures (italics mean an expression goes here ): createcanvas(w, h); width height key background(r,

More information

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

Variables 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 information

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment

More information

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof. GridLang: Grid Based Game Development Language Language Reference Manual Programming Language and Translators - Spring 2017 Prof. Stephen Edwards Akshay Nagpal Dhruv Shekhawat Parth Panchmatia Sagar Damani

More information

Visual C# Program: Simple Game 3

Visual C# Program: Simple Game 3 C h a p t e r 6C Visual C# Program: Simple Game 3 In this chapter, you will learn how to use the following Visual C# Application functions to World Class standards: Opening Visual C# Editor Beginning a

More information

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

Using 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 information

Plotting Points. By Francine Wolfe Professor Susan Rodger Duke University June 2010

Plotting Points. By Francine Wolfe Professor Susan Rodger Duke University June 2010 Plotting Points By Francine Wolfe Professor Susan Rodger Duke University June 2010 Description This tutorial will show you how to create a game where the player has to plot points on a graph. The method

More information

Midterms Save the Dates!

Midterms Save the Dates! University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Primitive Data Types Arithmetic Operators Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch 4.1-4.2.

More information

Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture - 23 Introduction to Arduino- II Hi. Now, we will continue

More information

Programming Project 1

Programming Project 1 Programming Project 1 Handout 6 CSCI 134: Fall, 2016 Guidelines A programming project is a laboratory that you complete on your own, without the help of others. It is a form of take-home exam. You may

More information

Processing Assignment Write- Ups

Processing 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 information

5.1. Examples: Going beyond Sequence

5.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 information

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

void mouseclicked() { // Called when the mouse is pressed and released // at the same mouse position } Review Commenting your code Random numbers and printing messages mousex, mousey void setup() & void draw() framerate(), loop(), noloop() Arcs, curves, bézier curves, beginshape/endshape Example Sketches

More information

Character Modeling IAT 343 Lab 6. Lanz Singbeil

Character Modeling IAT 343 Lab 6. Lanz Singbeil Character Modeling IAT 343 Lab 6 Modeling Using Reference Sketches Start by creating a character sketch in a T-Pose (arms outstretched) Separate the sketch into 2 images with the same pixel height. Make

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

How to draw and create shapes

How to draw and create shapes Adobe Flash Professional Guide How to draw and create shapes You can add artwork to your Adobe Flash Professional documents in two ways: You can import images or draw original artwork in Flash by using

More information

INTRODUCTION 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 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 information

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

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca COMP 1010- Summer 2015 (A01) Jim (James) Young young@cs.umanitoba.ca jimyoung.ca final float MAX_SPEED = 10; final float BALL_SIZE = 5; void setup() { size(500, 500); void draw() { stroke(255); fill(255);

More information

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

University 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 information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information

Processor. Lecture #2 Number Rep & Intro to C classic components of all computers Control Datapath Memory Input Output

Processor. Lecture #2 Number Rep & Intro to C classic components of all computers Control Datapath Memory Input Output CS61C L2 Number Representation & Introduction to C (1) insteecsberkeleyedu/~cs61c CS61C : Machine Structures Lecture #2 Number Rep & Intro to C Scott Beamer Instructor 2007-06-26 Review Continued rapid

More information

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

What is a variable? A named locajon in the computer s memory. A variable stores values Chapter 4 Summary/review coordinate system basic drawing commands and their parameters (rect, line, ellipse,background, stroke, fill) color model - RGB + alpha Processing IDE - entering/saving/running

More information

CST112 Looping Statements Page 1

CST112 Looping Statements Page 1 CST112 Looping Statements Page 1 1 2 3 4 5 Processing: Looping Statements CST112 Algorithms Procedure for solving problem: 1. Actions to be executed 2. Order in which actions are executed order of elements

More information

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

Conditional 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 information

2 Ranking Task: complete this section and submit it to your instructor before you begin the lab.

2 Ranking Task: complete this section and submit it to your instructor before you begin the lab. Experiment 2 Ranking Task: complete this section and submit it to your instructor before you begin the lab. The position vs. time graph below was made by a moving object. During certain times, the object

More information

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

CS110 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

Exploring Processing

Exploring Processing Exploring Processing What is Processing? Easy-to-use programming environment Let s you edit, run, save, share all in one application Designed to support interactive, visual applications Something we ve

More information

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently. The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without

More information

CMPT-166: Sample Final Exam Answer Key

CMPT-166: Sample Final Exam Answer Key CMPT 166, Summer 2012, Surrey Sample Final Exam Answer Key Page 1 of 9 CMPT-166: Sample Final Exam Answer Key Last name exactly as it appears on your student card First name exactly as it appears on your

More information

CS 139 Practice Midterm Questions #2

CS 139 Practice Midterm Questions #2 CS 139 Practice Midterm Questions #2 Spring 2016 Name: 1. Write Java statements to accomplish each of the following. (a) Declares numbers to be an array of int s. (b) Initializes numbers to contain a reference

More information

A B C D CS105 03a Interaction

A 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 information

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

Repetition 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 information

Computer Graphics. Interaction

Computer Graphics. Interaction Computer Graphics Interaction Jordi Linares i Pellicer Escola Politècnica Superior d Alcoi Dep. de Sistemes Informàtics i Computació jlinares@dsic.upv.es http://www.dsic.upv.es/~jlinares processing allows

More information

Interaction Design A.A. 2017/2018

Interaction 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 information

SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC

SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC Photo Effects: Snowflakes Photo Border (Photoshop CS6 / CC) SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC In this Photoshop tutorial, we ll learn how to create a simple and fun snowflakes photo border,

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

LAB 02: Graph Matching

LAB 02: Graph Matching LAB 02: Graph Matching One of the most effective methods of describing motion is to plot graphs of position/displacement, velocity, and acceleration vs. time. From such a graphical representation, it is

More information

Chapter 7 Applets. Answers

Chapter 7 Applets. Answers Chapter 7 Applets Answers 1. D The drawoval(x, y, width, height) method of graphics draws an empty oval within a bounding box, and accepts 4 int parameters. The x and y coordinates of the left/top point

More information

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java Chapter 3 Syntax, Errors, and Debugging Objectives Construct and use numeric and string literals. Name and use variables and constants. Create arithmetic expressions. Understand the precedence of different

More information

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming s SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177 Programming Time allowed: THREE hours: Answer: ALL questions Items permitted: Items supplied: There is

More information

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

This assignment was revised from the original PDF released to revise/add Parts D and E. Behind the Digital Screen Assignment 5: Visualization Deadline: Monday, 4/11, 3pm (one hour before class begins) This assignment was revised from the original PDF released to revise/add Parts D and E.

More information

Give one example where you might wish to use a three dimensional array

Give one example where you might wish to use a three dimensional array CS 110: INTRODUCTION TO COMPUTER SCIENCE SAMPLE TEST 3 TIME ALLOWED: 60 MINUTES Student s Name: MAXIMUM MARK 100 NOTE: Unless otherwise stated, the questions are with reference to the Java Programming

More information

McGill University School of Computer Science COMP-202A Introduction to Computing 1

McGill University School of Computer Science COMP-202A Introduction to Computing 1 McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif

More information

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba Before writing a program to solve a problem, have a thorough understanding of the problem and a carefully planned approach to solving it. Understand the types of building

More information

: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics

: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics Assignment 1: Turtle Graphics Page 1 600.112: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics Peter H. Fröhlich phf@cs.jhu.edu Joanne Selinski joanne@cs.jhu.edu Due Date: Wednesdays

More information

QuickTutor. An Introductory SilverScreen Modeling Tutorial. Solid Modeler

QuickTutor. An Introductory SilverScreen Modeling Tutorial. Solid Modeler QuickTutor An Introductory SilverScreen Modeling Tutorial Solid Modeler TM Copyright Copyright 2005 by Schroff Development Corporation, Shawnee-Mission, Kansas, United States of America. All rights reserved.

More information

CS 106 Winter Lab 03: Input and Output

CS 106 Winter Lab 03: Input and Output CS 106 Winter 2019 Lab 03: Input and Output Due: Wednesday, January 23th, 11:59pm Summary This lab will allow you to practice input and output. Each question is on a separate page. SAVE each sketch as

More information