Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3648164
  • 博文数量: 365
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2522
  • 用 户 组: 普通用户
  • 注册时间: 2019-10-28 13:40
文章分类

全部博文(365)

文章存档

2023年(8)

2022年(130)

2021年(155)

2020年(50)

2019年(22)

我的朋友

分类: Python/Ruby

2022-09-13 11:57:59

class Mooncake2:

    def __init__(self,x_distante,y_distante,name):

        turtle.home()

        turtle.setup(1100, 600)

        # 月饼最外层边数

        self.bian = 8

        self.ext_r = 100

        self.x_distante= x_distante

        self.y_distante = y_distante

        self.name = name

        self.yuebing_zhong()

    def yuebing_zhong(self):

        turtle.color("#FFD700")

        round_r = 跟单网gendan5.commath.sin(math.pi / self.bian) * self.ext_r  # 月饼花圈的半径

        # 从水平x轴出发

        for i in range(self.bian):

            turtle.home()

            # print(turtle.xcor(), turtle.ycor())

            turtle.penup()  # 画笔抬起

            turtle.goto(self.x_distante,0)  # 恢复为初始位置

            turtle.seth((360 / self.bian) * i)  # 改变画笔方向,但不前进

            turtle.fd(self.ext_r)

            turtle.left((360 / self.bian) * 0.8)  # 画笔左转一定的角度

            turtle.color('#FF8C00')  # 设置颜色

            turtle.begin_fill()  # 开始填充颜色

            turtle.circle(round_r, extent=180)

            turtle.end_fill()

        self.inner_circle()

    def inner_circle(self):

        turtle.penup()

        turtle.goto(0+self.x_distante,100+self.y_distante)

        turtle.seth(0)

        turtle.pendown()

        turtle.color('#F0BE7C')

        turtle.begin_fill()

        turtle.circle(-self.ext_r)

        turtle.end_fill()

        self.Moon_inner()

    def Moon_inner(self):

        turtle.color('#FFD700')

        turtle.goto(0+self.x_distante,-self.ext_r-self.y_distante)

        turtle.left(0)

        turtle.begin_fill()

        turtle.circle(100,steps=6)

        turtle.end_fill()

        self.TP()

    def TP(self):

        self.pingan()

    def pingan(self):  

        turtle.penup()

        turtle.goto(-30+self.x_distante,0+self.y_distante)

        turtle.color('#FF8C00')

        turtle.write("", font=("楷体", 50, "bold"))

        turtle.goto(-30+self.x_distante, -60+self.y_distante)

        turtle.write("", font=("楷体", 50, "bold"))

        turtle.ht()

阅读(635) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~