turtle.turtlesize() function in Python
Last Updated :
26 Jul, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
turtle.turtlesize()
This function is used to return or set the pen’s attributes x or y-stretchfactors and outline.
Syntax :
turtle.turtlesize(stretch_wid=None, stretch_len=None, outline=None)
Parameters:
Arguments |
Value Type |
Description |
stretch_wid |
positive number |
stretchfactor perpendicular to orientation |
stretch_len |
positive number |
stretchfactor in direction of turtles orientation |
outline |
positive number |
determines the width of the shapes’s outline |
Below is the implementation of the above method with some examples :
Example 1 :
Python3
import turtle
turtle.speed( 1 )
turtle.shape( "turtle" )
turtle.fillcolor( "blue" )
for i in range ( 4 ):
turtle.turtlesize(stretch_wid = (i + 1 ) * 0.5 )
turtle.forward( 100 )
turtle.right( 90 )
|
Output :
Example 2 :
Python3
import turtle
turtle.speed( 1 )
turtle.shape( "turtle" )
turtle.fillcolor( "blue" )
for i in range ( 4 ):
turtle.turtlesize(stretch_len = (i + 1 ) * 0.5 )
turtle.forward( 100 )
turtle.right( 90 )
|
Output :
Example 3 :
Python3
import turtle
turtle.speed( 1 )
turtle.shape( "turtle" )
turtle.fillcolor( "blue" )
for i in range ( 4 ):
turtle.turtlesize(outline = i + 1 )
turtle.forward( 100 )
turtle.right( 90 )
|
Output :
Example 4 :
Python3
import turtle
turtle.speed( 1 )
turtle.shape( "turtle" )
turtle.fillcolor( "blue" )
for i in range ( 4 ):
turtle.turtlesize(stretch_wid = (i + 1 ) * 0.5 ,
stretch_len = (i + 1 ) * 0.5 ,
outline = (i + 1 )
)
turtle.forward( 100 )
turtle.right( 90 )
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...