Turtle Graphics Let’s see what we can draw on Python!

Slides:



Advertisements
Similar presentations
First of all – lets look at the windows you are going to use. At the top you have a toolbar, with all your various tools you can use when customising your.
Advertisements

Graphics Shapes. Setup for using graphics You have to import the graphics library You can use either “import graphics” or “from graphics import *” or.
CS 100: Roadmap to Computing Fall 2014 Lecture 02: Fun With Turtles.
Week 8 - Monday.  What did we talk about last time?  StdAudio.
Week 7: Input and Output 1.  Now we are going to talk a little bit about output  You have a lot of experience with System.out.println() and System.out.print()
SuperStar Basics Brian Bruderer. Sequence Editors Traditional sequence editors use a large grid to control when channels are turned on and off. This approach.
PYTHON TURTLE WORLD : CHAPTER 4 FROM THINK PYTHON HOW TO THINK LIKE A COMPUTER SCIENTIST.
Lecture 2. Review To play with Turtle, we need to download and install followings: 1.JDK 6 2.Dr. Java 3.Sample program (e.g. BookClass)
Programming in Python Turtle Graphics Dr. Kristine Nagel Genie Yang Raquel Lawrence Dr. Kristine Nagel Genie Yang Raquel Lawrence Georgia Gwinnett College.
Introduction to TouchDevelop
DIGITAL GRAPHICS & ANIMATION
B.A. (Mahayana Studies) Introduction to Computer Science November March Logo (Part 1) An introduction to Logo: drawing, moving,
Introduction to Scratch!
VIDEO GAME PROGRAMMING Video Game Programming Junior – DigiPutt INSTRUCTOR TEACHER’S ASSISTANT.
Introducing Scratch the Cat
Microsoft® Small Basic
Georgia Institute of Technology Barb Ericson Georgia Institute of Technology May 2006 Teaching Java using Turtles part 2.
Class 2 Introduction to turtle graphics
Turtle see, turtle do Lesson 1 – Welcome to LOGO.
Agent P, I have been hearing some rumours about a Python Turtle.
Copyright © Curt Hill Turtles The beginning of media computation.
TURTLE GRAPHICS IP MR. MELLESMOEN. LOGO IN THE 1970’S THERE WAS A SIMPLE BUT POWERFUL PROGRAMMING LANGUAGE CALLED LOGO THAT WAS USED BY A FEW.
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.
Moving Sprites in Scratch Exploring Computer Science – Lesson 4-4.
CONTROL SYSTEMS Control Systems A command is a directive that performs a specific task An argument is a variable that can be used by the function reveiving.
Java Introduction part 2 CSC1401. Overview In this session, we are going to examine some of the instructions from the previous class in more detail.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Canvas Class- Submit An Assignment in Canvas Spring 2014 By- PCI Librarian.
GRAPHICS MODULE 14 STUDY BOOK. Graphic commands SCREEN - puts the screen into graphics mode WINDOW - allows scaling of the screen LINE - 3 formats –LINE.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Computer Programming Modeling a Passive Solar Home.
1 Building Your Own Turtle Functions For making really cool pictures!
How to make a Tessellation By: Tyler Gaucher. First you open up paint and make a box, To make a box you click on the blue box on the left side. Then draw.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
+ HTML Hypertext Markup Language. + Introducing HTML HTML is the language used in writing websites Open the “HTML Practice” link on the Daily Log Delete.
Let’s Learn 3. Modules Saenthong School, January – February 2016
Simple Turing Graphics Woof, Bark, Bark. The Screen (0,0)(600,0) (600,400)(0,400) (150,300) First line of code: View.Set(“graphics:600;400”)
Intro to Turtle Graphics (Part 2)
First of all – lets look at the window’s you are going to use. At the top you have a toolbar, with all your various tools you can use when customising.
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.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
Turtle Graphics Just keep swimming …. Fill Shapes turtle.fillcolor(“#color_code”) turtle.begin_fill() turtle.end_fill() ■You must tell turtle when to.
Introducing the turtle
Creating Web Pages in Word. Sharing Office Files Online Many Web pages are created using the HTML programming language. Web page editors are software.
Python Turtle Graphics
Computer Programming.
Graphics CIS 40 – Introduction to Programming in Python
Introduction to Python
Intro CS – Loops & Creating Shapes
Going Green By Ima Librarian
Let’s see what we can draw on Python!
A Tiny Look at the Graphics Window
Agent P, I have been hearing some rumours about a Python Turtle.
Learning to program with Logo
Frozen Graphics Lesson 3.
CS 100: Roadmap to Computing
Let’s make a shape…. Move!
Microsoft® Small Basic
Who doesn’t like a turtle who can do art?
CS 100: Roadmap to Computing
Teaching Java using Turtles part 2
WICS - Flappy Anteater Python Tutorial
Suppressing print Newline
Section 3 Programming with Turtle Graphics
Download and Installation of code::blocks
Simple Graphics Package
Introduction to Turtle Graphics
A Tiny Look at the Graphics Window
Teaching Java using Turtles part 2
Background for lab: the ord() function
Presentation transcript:

Turtle Graphics Let’s see what we can draw on Python!

Turtle Graphics  Turtle graphics is a method of programming “vector” graphics using a relative cursor upon a Cartesian plane (in other words, Turtle uses the foundation of a coordinate plane in order to help draw it’s graphics)  Python has a built-in module that supports turtle graphics called “turtle”  Importing this module gives you access to all the functions necessary in order to draw vectors on the screen

Turtle Graphics  In Turtle, you control a cursor, also know as the “turtle”  It has the following properties: 1.A position in 2D space on the coordinate plane 2.An orientation, or heading 3.A pen that can lay down color on the canvas

Turtle Graphics  In Turtle, you control a cursor, also know as the “turtle”  It has the following properties: 1.A position in 2D space on the coordinate plane 2.An orientation, or heading 3.A pen that can lay down color on the canvas

Setting up your environment #first we need to import the turtle module import turtle # set a title for your window turtle.title(“My turtle animation”) # set up the screen size (in pixels – 400 x 400) # set up the starting point of the turtle (0,0) – origin turtle.setup(400,400,0,0)

Setting up your environment  Because we are unable to download Python onto our computers, we will be using a website called:  However this website was somewhat created for the sake of using Turtle, not so much Python in it’s entirety  So, the environment is already set up for you as a 400 x 400 canvas window and the turtle is set to start at the origin (0, 0)

trinket.io/Python

Important Note!  Do not name your Python source code file “turtle.py”  This will prevent Python from finding the correct “turtle.py” module when using the import turtle statement at the top of your program

Getting rid of your turtle window  This function call will cause your turtle window to deactivate when you click on it. Place it at the end of your turtle program. turtle.exitonclick()  This will not be applicable on our website

Basic Turtle Functions  You can move your turtle forward by using the following command: turtle.forward(pixels) #pixels can also be denoted by the number of spaces you want to move  And you can have your turtle turn by using the following commands: turtle.right(degrees) turtle.left(degrees)  Your turtle will continually “draw” while it’s moving

Programming Challenge  Draw a box!

Programming Challenge  Draw a regular pentagon

Moving your turtle  You can also command your turtle to move to any coordinate on the screen by using the turtle.goto() function  This function accepts two arguments, x and y, denoting the x and y coordinates on the coordinate plane turtle.goto(50,50)  Note however that your pen will continue to draw as you move your turtle to a new position

Moving your turtle  You may have guessed that if your pen keeps on drawing, you may end up with a bunch of lines that you might not want …  You can tell the turtle to stop drawing by using the turtle.penup() function. You can tell the turtle to start drawing again by using the turtle.pendown() function

Programming Challenge – Four Squares  Try drawing four squares, keep in mind that when you overlap your lines, you won’t really be able to tell because it will show up as a single line on Python, however try not to overlap!