Computer Science I Fonts. Building on one jigsaw to make another.

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
Arduino Part 2 Topics: Serial Communication Programming Constructs: functions, loops and conditionals Digital Input.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Keyboard and Events. What about the keyboard? Keyboard inputs can be used in many ways---not just for text The boolean variable keyPressed is true if.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02b: Tutorial for Programming in Processing Jarek Rossignac.
CIS 3.5 Lecture 2.2 More programming with "Processing"
Computer Science I Programming in Java (programming using Processing IN Java, using IntelliJ IDE) Classwork/Homework: copy your Processing projects over.
Computer Science I Recap: variables & functions. Images. Pseudo-random processing.
Computer Science I Looping. User input. Classwork/Homework: Incorporate looping & user input into a sketch.
Creating a Java Application and Applet
Computer Science I Share plans for virtual something. Text. Show my virtual dog. Classwork: Plans for your virtual something. Homework: start implementation.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
Computer Science I Variables. Methods. Classwork/Homework: Re-do or do new drawing using variables & function(s). Zip folder and upload to Moodle dropbox.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
Computer Science I Text input. Transformations. Yet another jigsaw. Classwork/Homework: Create new application making use of transformations.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
Computer Science I Go over midterm. Reprise on curves. Table examples. The map function. Testing Strings. Fonts. Classwork/Homework: Complete midterm project.
Computer Science I Looking at code: "Where did Prof. Shablinsky go" Classwork/homework: midterm projects.
Computer Science I More class examples. Paths. Jigsaw. Tolerance. Classwork/homework: Your class project. Post proposal for midterm project.
Time to upload Virtual something.
Loops. About the Midterm Exam.. Exam on March 12 Monday (tentatively) Review on March 5.
Lesson 3 Functions. Lesson 3 Functions are declared with function. For example, to calculate the cube of a number function function name (parameters)
Modifying GridWorld Classes.
3.1 Fundamentals of algorithms
Content Programming Overview The JVM A brief look at Structure
Manipulating Pictures, Arrays, and Loops part 2
Classwork: Examine and enhance falling drop(s) or make your own.
Computer Science I Variables. Methods.
Click the mouse button or press the Space Bar to display the answers.
Eclipse Navigation & Usage.
Classes and Objects in Java
Chapter-7 part3 Arrays Two-Dimensional Arrays The ArrayList Class.
Control Structures
Namespaces, Scopes, Access privileges
Computation as an Expressive Medium
Manipulating Pictures, Arrays, and Loops part 2
Manipulating Pictures, Arrays, and Loops part 2
What does the backwards “B” tell us about the characters?
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
Java Programming with BlueJ
Board: Objects, Arrays and Pedagogy
Chapter 8 Slides from GaddisText
Exam 1 Material Study Guide
Introduction to TouchDevelop
More programming with "Processing"
Arrays
Programming games Classes and objects (used for Jigsaw, Bouncing stuff, other projects) Homework: Complete cannonball. Video or Audio. Your own project.
Chapter 7 Part 2 Edited by JJ Shepherd
Control structures Chapter 3.
Classes and Objects in Java
Control structures Chapter 3.
Review for Final Exam.
Fall 2018 CISC124 2/24/2019 CISC124 Quiz 1 marking is complete. Quiz average was about 40/60 or 67%. TAs are still grading assn 1. Assn 2 due this Friday,
CLASSES, AND OBJECTS A FIRST LOOK
Overview of Java 6-Apr-19.
CSCI N207 Data Analysis Using Spreadsheet
Control structures Chapter 3.
Classes CS 21a: Introduction to Computing I
More on Creating Classes
Programming games Share your plans for your virtual something.
LCC 6310 Computation as an Expressive Medium
Manipulating Pictures, Arrays, and Loops
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
CMPE212 – Reminders Quiz 1 marking done. Assignment 2 due next Friday.
Running a Java Program using Blue Jay.
Classes and Objects in Java
Lesson 3. Controlling program flow. Loops. Methods. Arrays.
Presentation transcript:

Computer Science I Fonts. Building on one jigsaw to make another. Classwork: Virtual Something

Check out Emmie’s comic in Course Announcements A class is a blue print. Your code makes use of it Invoke the constructor to create the object Mainly initial setting of variables Invoke other methods for other behavior

Available Fonts Pfont.list is a class method that returns an array of all fonts available on the computer. A class method is independent of any specific object. In Java, we can create class methods using the modifier static.

Show fonts My sketch prints out the names of available fonts on the console and Displays text in specific, randomly selected font) after mouse click.

My sketch: showfonts String[] fontList ; PFont myfont; void setup() { size(800, 600); fill(255,0,0); fontList = PFont.list(); println(fontList); }

void draw() { } void mousePressed() { int ch = int(random(0,fontList void draw() { } void mousePressed() { int ch = int(random(0,fontList.length)); myfont = createFont(fontList[ch],20); textFont(myfont); text(fontList[ch],mouseX,mouseY);

Fonts The command textFont(somefont); only works if somefont has been set using loadFont or createFont Extra credit opportunity for a good explanation of loadFont versus createFont Not just copy and paste from the document Include uses

Opportunity New photo from Aviva's trip to Cuba. Want to make new jigsaw Make vertical and horizontal cuts. Some other changes, including text on the screen. Close enough. You can click Restore or Mix up to try again. Build on other "linear jigsaw" Lesson (subtext, meta message): much work already done.

Overview of linear jigsaw Classes: Button, Piece pieces is Array of Piece objects; buttons is Array of Button objects Global variables, all of which carry over Used for responsive design (adapt to screen size) Functions: setup, draw, mouseClicked, mousePressed, mouseDragged, mouseReleased makeButtons, drawButtons, makePieces, mixUpPieces, drawPieces

What needs to be changed or added? The Piece class needs to add variable for y position, so now there is locy as well as locx. The constructor method Piece has one more parameter: Piece(int locxC,int locyC,int x,int y, int w, int h) Substantial changes to makePieces function Where else? Use Find for statements involving locx or getpx.

Nested for loops Standard pattern for creating something corresponding to rows and columns Need looping variable for each for loop: i and j Need additional variable because I put all the pieces in a 1 dimensional array: use alli.

void makePieces()//the Piece constructor will cut //out the piece { pieces = new Piece[NoP]; int pi = 0; // index for populating pieces for (int i=0;i<NHor;i++) for (int j=0;j<NVer;j++) { // initial positions is determined randomly int rx = round(random(.75*displayWidth)); int ry = round(random(.75*displayHeight)); pieces[pi] = new Piece(wedgeW*i,wedgeH*j,rx,ry,wedgeW,wedgeH); pieces[pi].display(); pi++; }

Note The Piece constructor method does the actual work of creating the piece content = createImage(pw,ph,RGB); content.copy(originalA,locxC,locyC,pw,ph, 0,0,pw,ph);

Aside The class code provides the template (blue print, specification) for objects What is the data to be associated with each object What are the behaviors: what is done with or to the object. One behavior is creating the object. This one is called the constructor and is used with the new operator. No object exists until it is constructed. See Emmie's announcement

For example, checking if puzzle done From linear jigsaw: int perfectpx = firstx + i*wedgeW; int errorx = abs(perfectpx-pxi); int errory = abs(firsty-pyi);

2D jigsaw, in context for (int i=1;i<NoP;i++) { int pxi = pieces[i].getpx(); int pyi = pieces[i].getpy(); int perfectpx = firstx + pieces[i].getlocx(); int perfectpy = firsty + pieces[i].getlocy(); int errorx = abs(perfectpx-pxi); int errory = abs(perfectpy-pyi); if ((errorx>tolerance) || (errory>tolerance)) { oksofar = false; break; } }

Show the rest, to show text if (oksofar) { text("Close enough. You can click Restore or Mix up to try again.",500,20); phase = 1; } "okay so far" coding This uses the default text font and size. Could be bigger. May be opportunity for sound!

Assignments Must use the naming convention jMeyerMyDog Must zip (compress) the containing folder Not just the pde file, not just the data file Must have evocative names for variables and functions and classes Must have comments At start of code saying what it does Elsewhere indicating logic, assumptions What a function does. What the parameters represent. Where you may have wanted to do something more.

Classwork Use new techniques? Complete and upload your virtual something.