# 用矩形绘制花瓣
from turtle import *
def square(size=50,rgb='pink'):
    pencolor(rgb)
    for i in range(4):
        fd(size)
        left(90)

def main():
    setup(800,600)
    speed(0)

    n=10
    for i in range(n):
        square(80,'orange')
        left(360/n)

    hideturtle()
    done()

from turtle import *
setup(800,600)
pencolor('pink')

n = 10
for i in range(n):
    # 绘制一片花瓣
    for j in range(2):
        circle(80,90)
        left(90)
        speed(0)

    right(360/n)

hideturtle()
done()

# 绘制螺旋状正方形、五边形
from turtle import *
help(circle)
setup(800,600)
bgcolor('black')
pencolor('white')
speed(0)

angle = 0
size = 2

n=10
for i in range(n):
    for j in range(4):
        fd(size)
        angle += 360/5
        seth(angle)
        size += 5

hideturtle()
done()

from turtle import *
from random import random

def rect(width, high):
    for i in range(2):
        fd(width)
        right(90)
        fd(high)
        right(90)


setup(800, 600)
speed(0)
penup()
goto(-80,0)
pendown()
right(180)

for i in range(20):
    rgb = tuple(random() for i in range(3))
    color(rgb)
    begin_fill()
    rect(8, 16)
    end_fill()
    penup()
    goto(-80+8*i+8, 0)
    pendown()

hideturtle()
done()

 

posted on 2022-06-13 22:09  清橙往忆  阅读(6)  评论(1编辑  收藏  举报