Simple Python Turtle Graphic and Code: colorsys hsv 3

Описание к видео Simple Python Turtle Graphic and Code: colorsys hsv 3

A stylized set of leaves made a bit different by applying saturation values in hsv from 0.8 to 0.

Feel free to copy the simple 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 manually colorable graphics and variations, please visit my author site at https://www.amazon.com/author/basicpy...

import turtle
import colorsys #Call to use the colorsys module for hue, saturation, and value (hsv) color dimensions
t = turtle.Turtle() #Definitions and Initializations
screen = turtle.Screen()
s = 0.8 #Initial value of color saturation at 0.8
screen.bgcolor("white") #Assignment of background color
t.pensize(8)
t.speed(10)
radius = 250 #Size of graphic; Generating radius for the biggest arcs
number_of_leaf_contours = 20 #Count of leaf sets, each one composed of four
change_in_radius = radius / \
(2 * number_of_leaf_contours) #Length adjustment of generating radius for succeeding arcs
def four_leaves(s, radius): #Procedure for drawing a leaf set with given saturation and radius values
c = colorsys.hsv_to_rgb(0.8, s, 1) #Assignment of color for current leaf set using the hsv format
t.color(c)
t.circle(radius, 90) #Initial arc -- 90 degrees -- in a leaf set
for i in range(3): #Three succeeding arcs -- 180 degrees -- in a leaf set
t.left(90)
t.circle(radius, 180)
t.left(90)
t.circle(radius, 90) #Final arc -- 90 degrees -- in a leaf set
for i in range(number_of_leaf_contours): #Python_Graphic start of drawing procedure
four_leaves(s, radius) #Function call to draw a leaf set with given saturation and radius
s -= 0.8 / number_of_leaf_contours #Decrease in saturation value for next leaf set
radius -= change_in_radius #Decrease in generating radius for arcs in next leaf set
t.hideturtle()
screen.exitonclick()

Комментарии

Информация по комментариям в разработке