美文网首页python学习笔记
python练手_59-画图(丑)

python练手_59-画图(丑)

作者: 学子CH | 来源:发表于2019-02-17 17:50 被阅读0次
    # -*- coding:utf-8 -*-
    # @Author: CH
    """
    @project: python study
    @time:2019/1/7-23:53
    @file_name:【程序59】画图(丑).py
    @IDE:PyCharm 
    @else: DO NOT STOP STUDYING!!!
    """
    # 题目 画图,综合例子。
    #
    # 程序分析 丑。
    if __name__ == '__main__':
        from tkinter import *
    
        canvas = Canvas(width=300, height=300, bg='green')
        canvas.pack(expand=YES, fill=BOTH)
        x0 = 150
        y0 = 100
        canvas.create_oval(x0 - 10, y0 - 10, x0 + 10, y0 + 10)
        canvas.create_oval(x0 - 20, y0 - 20, x0 + 20, y0 + 20)
        canvas.create_oval(x0 - 50, y0 - 50, x0 + 50, y0 + 50)
        import math
    
        B = 0.809
        for i in range(16):
            a = 2 * math.pi / 16 * i
            x = math.ceil(x0 + 48 * math.cos(a))
            y = math.ceil(y0 + 48 * math.sin(a) * B)
            canvas.create_line(x0, y0, x, y, fill='red')
        canvas.create_oval(x0 - 60, y0 - 60, x0 + 60, y0 + 60)
    
        for k in range(501):
            for i in range(17):
                a = (2 * math.pi / 16) * i + (2 * math.pi / 180) * k
                x = math.ceil(x0 + 48 * math.cos(a))
                y = math.ceil(y0 + 48 + math.sin(a) * B)
                canvas.create_line(x0, y0, x, y, fill='red')
            for j in range(51):
                a = (2 * math.pi / 16) * i + (2 * math.pi / 180) * k - 1
                x = math.ceil(x0 + 48 * math.cos(a))
                y = math.ceil(y0 + 48 * math.sin(a) * B)
                canvas.create_line(x0, y0, x, y, fill='red')
        mainloop()
    
    

    相关文章

      网友评论

        本文标题:python练手_59-画图(丑)

        本文链接:https://www.haomeiwen.com/subject/vaameqtx.html