Class 7 coordinates: pixel and with setCoords aspect ratio Rectangle

Slides:



Advertisements
Similar presentations
Python Programming: An Introduction to Computer Science
Advertisements

Python Programming: An Introduction to Computer Science
Graphics Shapes. Setup for using graphics You have to import the graphics library You can use either “import graphics” or “from graphics import *” or.
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
Working with images and scenes CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.5 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Python Programming, 2/e1 CS177: Programming in Multimedia Objects Recitation Topic: Graphics Library.
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
CS 280 Data Structures Professor John Peterson. Quiz 4 Recap Consider the following array: {2, 6, 7, 3, 4, 1, 5, 9}. Draw this in tree form and then show.
ObjectDraw and Objects Early Chris Nevison Barbara Wells.
1 Python Programming: An Introduction to Computer Science Chapter 3 Objects and Graphics.
OOP and Graphics. Object Oriented Programming The ‘classic’ point of view of a programmer was that the program instructions were the active part, the.
Chapter 4 Objects and Graphics
Python: Graphics
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
CSC 110 Objects and Graphics [Reading: chapter 4] CSC 110 E 1.
Chapter 3 Working with Symbols and Interactivity.
Chapter 5 Graphics.  We’ve been doing command line programming, but now it’s time to try GUI programming—programming in a graphical user interface, using.
Introduction to Programming Writing Java Beginning Java Programs.
Working with Symbols and Interactivity
Graphics Concepts CS 2302, Fall /3/20142 Drawing Paths.
Hello, little turtles. Hello, little turtles! There are many modules in Python that provide very powerful feature that we can use in our own program.
Lec 16 Adding Mouse and KeyEvent handlers to an Applet Class.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Introduction to Programming Writing Java Beginning Java Programs.
Some Graphics CS303E: Elements of Computers and Programming.
Overview The Basics – Python classes and objects Procedural vs OO Programming Entity modelling Operations / methods Program flow OOP Concepts and user-defined.
Python Programming, 1/e1 Programming Thinking and Method (5a) Zhao Hai 赵海 Department of Computer Science and Engineering Shanghai Jiao Tong University.
CSC 1010 Programming for All Lecture 7 Input, Output & Graphics.
Xiaojuan Cai Computational Thinking 1 Lecture 5 Objects and Graphics Xiaojuan Cai (蔡小娟) Fall, 2015.
Computer Game Design ActionScript is… Object-oriented programming Everything you do in ActionScript does something to some object* Some objects.
1 Introduction to Graphics b The last one or two sections of each chapter of the textbook focus on graphical issues b Most computer programs have graphical.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
Interaction with Graphics Also displaying GIFs. Text Output on the graphics window There is a class called Text which will put the message on the graphics.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 4 Objects and Graphics.
10. MORE OBJECTS Rocky K. C. Chang October 18, 2015 (Based on from Charles Dierbach. Introduction to Computer Science Using Python and adapted from John.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 4 Objects and Graphics.
5. COMPUTING WITH GRAPHICS OBJECTS Dennis Y. W. Liu and Rocky K. C. Chang October 8, 2015 (Adapted from John Zelle’s slides)
Introduction to: Python and OpenSesame FOR PROS. OpenSesame In OpenSesame you can add Python in-line codes which enables complex experiment. We will go.
CS 115 Lecture 7 Graphics – coordinate systems, Text, Entry, aliases Taken from notes by Dr. Neil Moore.
UML2-1 UML Exercise A "draw" utility program lets users draw several geometric objects on a diagram. A geometric object may be a Circle, Rectangle, Square.
Graphics Lab: MyPaint Dan Maselko 1. MyPaint Description  For this assignment you will be implementing a very simple paint program.  You should be able.
Vahé Karamian Python Programming CS-110 CHAPTER 4 Objects and Graphics.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
CS 115 Lecture 6 Graphics Taken from notes by Dr. Neil Moore.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 4 Objects and Graphics Killer cars.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
ENGINEERING 1D04 Tutorial 4. What are we doing today? Focus Functions Scope of Variables Returning Values Objects Graphics library Aliasing Events Mouse.
Graphics Michael Liut ( ) Ming Quan Fu( ) Brandon Da Silva(
Graphics Taken from notes by Dr. Neil Moore & Dr. Debby Keen
OOP - Object Oriented Programming
Fundamentals of Python: First Programs
Catapult Python Programming Session 4
Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
Example: Card Game Create a class called “Card”
Python: Simple Graphics and Event-driven Programming
Graphics Part I Taken from notes by Dr. Neil Moore
Graphics Part I Taken from notes by Dr. Neil Moore
CS 115 Lecture Graphics II – coordinate systems, Text, Entry, aliases
Lesson 17: Building an App: Canvas Painter
CS 115 Lecture Graphics II – coordinate systems, Text, Entry, aliases
SSEA Computer Science: Track A
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
Items, Group Boxes, Check Boxes & Radio Buttons
Graphics Part I Taken from notes by Dr. Neil Moore
Simple Graphics Package
Which best describes the relationship between classes and objects?
Class 6 using the math library
Working with images and scenes
Presentation transcript:

Class 7 coordinates: pixel and with setCoords aspect ratio Rectangle drawing in a loop Text setText changing the extension of files Objects and Classes instance constructor instance variables methods

What are the coordinates of the four corners of the window? win = GraphWin("First",300,400)

What are the coordinates of the four corners of the window? win = GraphWin("First",300,400) win.setCoords(0,0,3,4)

What will we see? win = GraphWin("400 X 400",400,400) win.setCoords(0,0,4,4) circ=Circle(Point(2,2),1) circ.draw(win)

What will we see? win = GraphWin("400 X 400",400,400) win.setCoords(0,0,8,8) circ=Circle(Point(2,2),1) circ.draw(win)

What will we see? win = GraphWin("400 X 400",400,400) win.setCoords(0,0,2,8) circ=Circle(Point(2,2),1) circ.draw(win)

What will we see? win = GraphWin("400 X 400",400,400) win.setCoords(0,0,4,4) rect=\ Rectangle(Point(2,2),Point(3,3.9)) rect.draw(win)

What will we see? win = GraphWin("400 X 400",400,400) win.setCoords(0,0,4,4) for m in range(2,6): x=1+2*.1 p=Point(x,3) p.draw(win)

What will we see? win = GraphWin("400 X 400",400,400) win.setCoords(0,0,4,4) for m in range(2,6): x=1+2*.3 p=Point(x,3) c=Circle(p,0.1) c.draw(win)

Where will the text be drawn? p=(0,0) word=Text(p,"ABCDE") word.draw(win)

Where will the text be drawn? p=(2,2) word=Text(p,"ABCDE") word.draw(win)

What happens when you click the mouse? p=getMouse(); t=Text(p,"Hello") q=getMouse(); t.setText("Goodbye")

Downloading .py files from my website trouble downloading some .py files instead, download .txt file, change the extension to .py note this doesn't work for all kinds of files. Can't just change .docs to .txt. Can save a word file: "Save as" plain text, .txt

The Object of Objects Basic idea – view a complex system as the interaction of simpler objects. An object is a sort of active data type that combines data and operations. Objects know stuff (contain data) and they can do stuff (have operations). Objects interact by sending each other messages. Python Programming, 3/e Python Programming, 3/e

Using Graphical Objects Computation is performed by asking an object to carry out one of its operations. Last lab we manipulated GraphWin, Point, Circle, and Rectangle. These are examples of classes. Today we use Oval, Line, Text Python Programming, 3/e Python Programming, 3/e

Using Graphical Objects Each object is an instance of some class, and the class describes the properties of the instance. If we say that Augie is a dog, we are actually saying that Augie is a specific individual in the larger class of all dogs. Augie is an instance of the dog class. Python Programming, 3/e Python Programming, 3/e

Using Graphical Objects To create a new instance of a class, we use a special operation called a constructor. <class-name>(<param1>, <param2>, …) <class-name> is the name of the class we want to create a new instance of, e.g. Circle or Point. The parameters are required to initialize the object. For example, Point requires two numeric values. Python Programming, 3/e Python Programming, 3/e

Using Graphical Objects p = Point(50, 60) The constructor for the Point class requires two parameters, the x and y coordinates for the point. These values are stored as instance variables inside of the object. Python Programming, 3/e Python Programming, 3/e

Using Graphical Objects Only the most relevant instance variables are shown (others include the color, window they belong to, etc.) Python Programming, 3/e Python Programming, 3/e

Using Graphical Objects To perform an operation on an object, we send the object a message. The set of messages an object responds to are called the methods of the object. Methods are like functions that live inside the object. Methods are invoked using dot-notation: <object>.<method-name>(<param1>, <param2>, …) Python Programming, 3/e Python Programming, 3/e