3D design

Output

Source Code

import turtle as t
import colorsys

###############

t.bgcolor(‘black’)
t.speed(‘fastest’)
t.pensize(2)
hue=0.0
t.hideturtle()

###############

for i in range (1000):
color = colorsys.hsv_to_rgb(hue,1,1)
t.pencolor(color)
t.fd(i)
t.rt(98.5)
t.circle(50)
hue +=0.005

t.exitonclick()

Code Description

This code uses the turtle graphics module to draw a spiral design with a changing color. The background color is set to black and the turtle’s speed is set to the fastest. The pen size is set to 2 and the turtle is hidden. The color of the pen changes with each iteration of the loop. The loop runs 1000 times, with each iteration the turtle moves forward by “i” units, turns right by 98.5 degrees, and draws a circle with a radius of 50. The hue value of the color is incremented by 0.005 with each iteration, creating a gradual color change for the spiral design. The code ends by using the exitonclick() method to close the turtle graphics window when the user clicks on it.