# Graphics, *Continued* --- CS 65 // 2021-02-18 ## Administrivia - About lab submissions... + From each lab, I typically assign **one** or two problems that must be turned in via codePost + You do NOT need to submit the rest of your solutions + However, they are there for practice, and I do recommend attempting them outside of class! ## Extra Credit Activities - [Career Conference](https://calendar.drake.edu/event/be_unstoppable_flexible_fearless_career_conference?utm_source=newsletter&utm_medium=email&utm_content=DETAILS&utm_campaign=Faculty-Feb-9#.YCLmlHdKhTY) + Friday, 2/19 from 9:00am to 4:00pm - [Songs for A New World](https://calendar.drake.edu/event/songs_for_a_new_world?utm_campaign=widget&utm_medium=widget&utm_source=Drake+University+Calendar) Livestream Performance + Thursday, 2/25 from 8:00 to 10:00am - [Global Citizen Forum](https://www.drake.edu/diversity/initiatives/globalcitizenforum2021/) + Conference on equity and inclusion in higher ed + March 3-5 # Assignment 3: Debrief # Exam 1 ## Exam 1 - Exam 1 is released - Be sure to carefully read the [exam procedures]( ../../resources/exam-procedures.html) before starting the exam - It is an **individual**, take-home exam + No discussing with peers, mentors, or tutors + You may only discuss the exam with me ## Tips for the Exam - Program little by little, saving often, and getting one piece to work at a time - Ask for help! + Come talk to me if you're stuck for a while - Test your programs on a variety of inputs - Start early # Object-Oriented Programming ## OO Programming - An **object** consists of the following: + A collection of related **information** + A set of **methods** (i.e. operations) to manipulate that information - For example, ```py p1 = Point(0,0) p2 = Point(1,1) rect = Rectangle(p1, p2) rect.setFill("blue") ``` The `rect` object is keeping track of all the information about a rectangle # Graphics Library ## Summary of Classes - **GraphWin** + A "window" that acts like a canvas that can be shown to the user. + Has a width / height, background color, and ways to get input from the user ## Summary of Classes - **GraphicsObject** + Any object that can be drawn to a GraphWin canvas has all the GraphicsObject methods + They have a position, fill color, outline color, etc. + The list of all GraphicsObject types are below: + Point, Line, Circle, Rectangle, Oval, Polygon, Text, Entry, and Image ## Getting Input from the User - You can interact with the user through the WinGraph window in four ways: + **getMouse()**: Waits for the user to click somewhere, and returns that point + **getKey()**: Waits for the user to press a key on the keyboard and returns a string + **checkMouse()**: Returns the last point the user clicked or None if they haven’t clicked recently + **checkKey()**: Returns the last key pressed or None if they haven’t pressed a key since ## Changing Coordinates - By default, when you construct a `GraphWin` the size is `200` by `200` pixels ```py win = GraphWin() ``` - You can change the size by constructing it with the constructor: ```py win = GraphWin("Title", 640, 480) ``` `640` is the width and `480` is the height in **pixels** ## Changing Coordinates ```py win = GraphWin("Title", 640, 480) ``` - The point `(0,0)` is the **upper-left corner** of `win` - and `(639, 479)` is the **lower-right corner** of `win` - This can be changed to any coordinate system you want by using the **setCoords** method ```py win.setCoords(0, 0, 2, 2) ``` - This changes the coordinate system so `(0,0)` is the **lower-left** corner and `(2,2)` is the **upper-right** # Lab Time