Tuesday, November 19, 2024
Google search engine
HomeLanguagesturtle.shearfactor() function in Python

turtle.shearfactor() function in Python

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.shearfactor()

This function is used to set or return the current shearfactor. It Shears the turtleshape according to the given shearfactor shear, which is the tangent of the shear angle. 

Syntax : turtle.shearfactor(shear=None)

Parameter: 

shear(optional): number, tangent of the shear angle.

Below is the implementation of the above method with some examples :

Example 1 :

Python3




# importing package
import turtle
  
# set turtle
turtle.speed(1)
turtle.shape("turtle")
turtle.up()
turtle.goto(-150,0)
turtle.down()
  
# forward turtle by 100
turtle.forward(100)
  
# set shear by +ive value
turtle.shearfactor(0.2)
  
# forward turtle by 100
turtle.forward(100)
  
# set shear by -ive value
turtle.shearfactor(-0.2)
  
# forward turtle by 100
turtle.forward(100)


Output :

Example 2 :

Python3




# importing package
import turtle
  
# set turtle 
turtle.speed(1)
turtle.up()
turtle.goto(-40,40)
turtle.down()
  
# set shear and apply to
# all shapes
turtle.shearfactor(0.5)
  
# get shape
sh=turtle.getshapes()
  
# loop for pattern
for i in range(len(sh)):
    turtle.shape(sh[i])
    turtle.forward(100+10*i)
    turtle.right(90)
    turtle.forward(100+10*i)
    turtle.right(90)


Output :

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments