Simple Python Turtle Graphic and Code: Deformed Triangles

Published: 18 November 2022
on channel: Basic Python Turtle Art
82
3

A circular arrangement of deformed triangles revealing a happy sun. A deformed triangle here is created by making each of its three sides wave-ish with two arcs. The Python Turtle code -- short with 25 lines only -- allows changing the number, size, and color of deformed triangles.

Feel free to copy the basic Python Turtle code that is given below. Don't hesitate to ask questions about the code if you have any. Enjoy! Please comment, like, or subscribe :)

Incidentally, for more graphics and variations, please visit my author url at https://www.amazon.com/author/basicpy...


import turtle
t = turtle.Turtle() #Definitions and Initializations
screen = turtle.Screen()
t.pensize(4)
radius_of_arcs_in_triangle_side = 45 #Radius of arcs that create an essy side of deformed triangle
number_of_deformed_triangles = 9 #Changeable, preferably close to 9
def deformed_triangle(): #Procedure for drawing a deformed triangle
t.fillcolor("red") #Start of fill color steps; Color changeable
t.begin_fill()
for i in range(3): #For 3 essy sides of deformed triangle
t.circle(radius_of_arcs_in_triangle_side, 120) #For first arc of side
t.circle(-(radius_of_arcs_in_triangle_side), 120) #For second arc of side; negative radius for clockwise drawing
t.right(120) #Turtle direction to draw next triangle side
t.end_fill() #Execution of color fill
t.penup() #Python_graphic start of drawing procedure
for i in range(number_of_deformed_triangles): #Loop for desired number of deformed triangles
t.forward(2 * radius_of_arcs_in_triangle_side) #Trail-less movement of turtle from center of graphic
t.right(30) #Turtle direction to start drawing of a deformed triangle
t.pendown() #start of drawing a deformed triangle
deformed_triangle() #Function call to draw a deformed triangle
t.penup() #For trail-less movement of turtle after drawing a triangle
t.home() #Turtle return to default location and direction
t.left((1 + i) * 360 / number_of_deformed_triangles) #Direction of turtle to draw the next deformed triangle
t.hideturtle()
screen.exitonclick()


On this page of the site you can watch the video online Simple Python Turtle Graphic and Code: Deformed Triangles with a duration of hours minute second in good quality, which was uploaded by the user Basic Python Turtle Art 18 November 2022, share the link with friends and acquaintances, this video has already been watched 82 times on youtube and it was liked by 3 viewers. Enjoy your viewing!