Drawing!. Why Drawing? Drawing is crucial to any graphical application Understanding.

Slides:



Advertisements
Similar presentations
Games in Python – the easy way
Advertisements

Introduction to Macromedia Director 8.5 – Lingo
Microsoft® Small Basic
Why ROOT?. ROOT ROOT: is an object_oriented frame work aimed at solving the data analysis challenges of high energy physics Object _oriented: by encapsulation,
Coordinate Systems John Kirby.
C HAPTER 12 A Very Graphic Story. O VERVIEW Simple GUI Getting User Input Creating a Listener ActionEvents Displaying Graphics Drawing Multiple Buttons.
Lab 1: OpenGL Tutorial CS 282. What’s the plan for today? Go over our framework code. Learn some basic OpenGL! Reveal Lab 1 Answer questions.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
2D Physics and Camera Systems For CSE 3902 By: Matt Boggus.
1 Windows Printing. 2 Objectives You will be able to Output text and graphics to a printer. Print multipage documents. Use the standard Windows print.
2 What is pyGame? A set of Python modules to make it easier to write games. –home page: –documentation:
Log on and Download from website:
Operating system Structure and Operation by Dr. Amin Danial Asham.
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
FLTK Help Session By Richard Yu Gu CS 638 -Graphics Fall, 1999.
KeyListener and Keyboard Events Another type of listener listens for keyboard entry – the KeyListener which generates KeyEvents –to implement KeyListener,
Class 2 Introduction to turtle graphics
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.
The Wait-Until-Event pattern Has it happened  Yes, it happened!
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
If..else Use random numbers to compute an approximation of pi Simulation of a special game of darts Randomly place darts on the board pi can be computed.
Adding Overlay Items.  So, now you have a map, but in many cases you'll also want to create your own map markers and lay-overs.  You must implement.
Dialog boxes in JavaScript Events in JavaScript – What are they – “Which events are there?” – “How do I register event handlers to an HTML element?” –
1 Graphics CSCI 343, Fall 2015 Lecture 6 Viewing, Animation, User Interface.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Event Handling Tonga Institute of Higher Education.
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 10: 3D & Projections Advanced.
Event Handling (the right way). A Simple Web Page Events - Summary The web page looks like this:
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
By JerryDean Smith Chad Adams Karl Mullner.  The rectangle needs to be a ogre.ManualObject -this is done to create the rectangle and gives it special.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
Turtle Graphics Let’s see what we can draw on Python!
Turtle Graphics Lesson 2 1. There are 3 homeworks to complete during the six lessons of this unit. Your teacher will let you know when a homework has.
Implement User Input Windows Development Fundamentals LESSON 2.4A.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
For vs. While loop count=0 while count< 5: for count in range(5):
Introduction to Python
Event Loops and GUI Intro2CS – weeks
COSC 1306 COMPUTER SCIENCE AND PROGRAMMING
Part II Reference:
PYGAME.
Introduction to Event-Driven Programming
ActionScript Basics 2016 (2.0 – 3.0)
Event loops 16-Jun-18.
Event Driven Programming Dick Steflik
"Digital Media Primer" Yue-Ling Wong, Copyright (c)2013 by Pearson Education, Inc. All rights reserved.
Lesson 1: Buttons and Events – 12/18
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
Event Driven Programming
Let’s make a shape…. Move!
Outline Announcements Dynamic Libraries HWII on web, due Friday
Event loops.
Extend Text Editor to Draw shapes
Functions, Regular expressions and Events
Graphics Part I Taken from notes by Dr. Neil Moore
Windowing Push-Pull Systems
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Professor John Canny Spring 2004 March 5
Event loops 8-Apr-19.
Event loops.
Professor John Canny Spring 2003 March 12
Event loops.
Event loops 19-Aug-19.
Using Modules.
Brown Bag Seminar Summer 2007
Bell Work Title: Turtle Intro Date:
Presentation transcript:

Drawing!

Why Drawing? Drawing is crucial to any graphical application Understanding

Window Basics Window size can be specified manually Any part of the window can be drawn on Windows can take user input (mouse events, and keyboard events)

The Co-ordinate System This is still a contested topic, though largely because many people are too lazy to change: 1.Old drawing systems matches CRT refresh, (0,0) is top-left, (width,height) is in bottom-right 2.Most new drawing systems use the positive portion of a cartesian plot (0,0) is bottom-left 3.Turtle in Python uses the whole cartesian plot

How Does Drawing Occur? Turtle uses something called Vector drawing, it works like human drawing. How do you draw? Get a pen Place the pen somewhere Move the pen and deposit ink

Configuring Turtle import turtle turtle.setup(400,500) wn = turtle.Screen() wn.title("Handling keypresses!") smiles = turtle.Turtle()

Drawing With Turtle #after the configuration smiles.pencolor("red") smiles.pendown() smiles.forward(100) smiles.right(90) smiles.forward(100)

Creating Drawing Functions For more complicated drawings it can be nice to define functions like drawing a complete triangle: def drawTriange(x,y,sideLength): smiles.begin_fill() # fill in the triangle after we finish drawing smiles.penup() smiles.setheading(0) smiles.goto(x,y) smiles.pendown() for i in range(3): smiles.forward(sideLength) smiles.left(120) smiles.end_fill()

Coding Break! Let’s do some drawing now, and then we can come back to take a look at handling events

What is an Event Handler? It’s something that handles events! More specifically it is a way for your program to respond to input from the user. The input() method allows for “blocking” event handling In many cases you don’t want to force user input at one point, but rather wait for it, and respond to it when it arrives

Adding Event Handlers Even handlers require 3 things: A method to be called when an event occurs A registration for that callback method, and event title Activating the window def forwardResponse(): smiles.forward(10) #we can also attach to Left,Right,q,etc… wn.onkey(forwardResponse, “Up”) wn.listen() wn.exitonclick()