Use python to draw Gypsophila dynamics, python Gypsophila drawing flow chart

This article mainly introduces the use of python to draw the dynamics of gypsophila, which has certain reference value. Friends in need can refer to it. I hope you will gain a lot after reading this article. Let the editor take you to understand it together.

import turtle
import random


def star():
    for i in range(5):
        turtle.fd(a)
        turtle.right(144)


def go():
    turtle.penup()
    turtle.goto(random.randint(-350, 350), random.randint(-350, 350))
    turtle.pendown()


# 三原色 red green blue
def colour():
    r = random.random()
    g = random.randint(0, 255) / 255
    b = random.randint(0, 255) / 255
    turtle.pencolor((r, g, b))


def main():
    turtle.width(5)
    a = 20
    turtle.speed(0)
    turtle.bgcolor('black')
    for w in range(100):
        star()
        go()
        colour()
    turtle.done()


if __name__ == '__main__':
    main()

Guess you like

Origin blog.csdn.net/chatgpt001/article/details/133515468