用turtle库画四朵随机的雪花

Posted Allen8

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用turtle库画四朵随机的雪花相关的知识,希望对你有一定的参考价值。

import turtle as t
import random as r

r.seed(1)
t.pensize(2)
t.color(\'red\')
angles = 6
points= [[0,0],[50,40],[70,80],[-40,30]]

for i in range(4):
    x0,y0 = points[i]
    t.penup()
    t.goto(x0,y0)
    t.pendown()

    length = r.randint(6, 16)
    for j in range(angles):
        t.fd(length)
        t.bk(length)
        t.right(360 / angles)
t.done()

用turtle画四朵随机的雪花

效果:

 

 

以上是关于用turtle库画四朵随机的雪花的主要内容,如果未能解决你的问题,请参考以下文章