Nothing Special   »   [go: up one dir, main page]

0% found this document useful (0 votes)
13 views12 pages

Graphics Using Python

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 12

TSSM’s & JSPM

PADMABHOOSHAN VASANTDADA PATILMINSTITUTE OF TECHNOLOGY


PUNE-21

A PROJECT BY:
SHASHWATI AND CHARUL
(First Year Engineering Depatment)

GUIDED BY:
PROF. PALLAVI MANKAR
GRAPHICS USING PYTHON
What is Turtle Graphics?
 Logo is an educational programming language designed in 1967 by Daniel
G. Bobrow, Wally Feurzeig, Seymour Papert and Cynthia Solomon.
 Today the language is remembered mainly for its use of “Turtle Graphics”
which commands for movement and drawing produced line graphics on
screen with a small pointer called a “Turtle”.
Turtle in Python

 To make graphic designs using Python, imagine a robotic turtle


starting at (0,0) in the x-y plane.
 Execute the import turtle Python command.
 This will import the turtle library so as to use the functions
already present in the library.
 We can use these functions to create our own graphic design.
Functions in Turtle Module
Method Parameter Description
Turtle() None Creates and returns a new turtle object
forward() amount Moves the turtle forward by the specified amount
backward() amount Moves the turtle backward by the specified amount
right() angle Turns the turtle clockwise
left() angle Turns the turtle counterclockwise
penup() None Picks up the turtle’s Pen
pendown() None Puts down the turtle’s Pen
up() None Picks up the turtle’s Pen
down() None Puts down the turtle’s Pen
Functions in Turtle Module
Method Parameter Description
color() Color name Changes the color of the turtle’s pen
fillcolor() Color name Changes the color of the turtle will use to fill a polygon
heading() None Returns the current heading
position() None Returns the current position
goto() x,y Move the turtle to position x,y
begin_fill() None Remember the starting point for a filled polygon
end_fill() None Close the polygon and fill with the current fill color
dot() None Leave the dot at the current position
stamp() None Leaves an impression of a turtle shape at the current
location
shape() shapename Should be ‘arrow’, ‘classic’, ‘turtle’ or ‘circle’
SPIROGRAPHIC
 To use the turtle library start with import turtle.

 For the background color we can use the turtle function bgcolor(). Set the
background color to black.

 Next we need to create the object turtle using Turtle() and store it in the
variable t.
SPIROGRAPHIC
 The colors purple and violet are used. We can define them here in a list.

 We need to set the speed of the robotic turtle in order to move it with a
uniform speed. The speed() function does this job.
SPIROGRAPHIC
 We can use a for loop here and loop about 400 times with the range()
function.

 With the forward() function we draw a straight line. Next we need to define
the angle. In one iteration of the loop we want to use purple, the next
iteration violet and keep alternating like that in each iteration.
SPIROGRAPHIC
 Finally let write turtle.done() to keep the screen open after
the code is done running.

 Now let us have a look to our final code.


SPIROGRAPHIC
THANK YOU

You might also like