python语言绘制自己的姓名及拼音缩写

系统 3307 0

利用turtle库绘制

效果图
python语言绘制自己的姓名及拼音缩写_第1张图片

代码:

            
              
                from
              
               turtle 
              
                import
              
              
                *
              
              
                def
              
              
                go
              
              
                (
              
              x
              
                ,
              
              y
              
                )
              
              
                :
              
              
    penup
              
                (
              
              
                )
              
              
    goto
              
                (
              
              x
              
                ,
              
              y
              
                )
              
              
    pendown
              
                (
              
              
                )
              
              
                def
              
              
                draw_firstname
              
              
                (
              
              
                )
              
              
                :
              
              
    seth
              
                (
              
              
                -
              
              
                90
              
              
                )
              
              
    fd
              
                (
              
              
                150
              
              
                )
              
              
                #seth()
              
              
    circle
              
                (
              
              
                -
              
              
                700
              
              
                ,
              
              
                23
              
              
                )
              
              
    penup
              
                (
              
              
                )
              
              
    goto
              
                (
              
              
                -
              
              
                500
              
              
                ,
              
              
                100
              
              
                )
              
              
    pendown
              
                (
              
              
                )
              
              
    seth
              
                (
              
              
                0
              
              
                )
              
              
    fd
              
                (
              
              
                300
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                90
              
              
                )
              
              
    fd
              
                (
              
              
                430
              
              
                )
              
              
    seth
              
                (
              
              
                140
              
              
                )
              
              
    fd
              
                (
              
              
                80
              
              
                )
              
              
    penup
              
                (
              
              
                )
              
              
    goto
              
                (
              
              
                -
              
              
                400
              
              
                ,
              
              
                15
              
              
                )
              
              
    pendown
              
                (
              
              
                )
              
              
    seth
              
                (
              
              
                0
              
              
                )
              
              
    fd
              
                (
              
              
                100
              
              
                )
              
              
    penup
              
                (
              
              
                )
              
              
    goto
              
                (
              
              
                -
              
              
                350
              
              
                ,
              
              
                50
              
              
                )
              
              
    pendown
              
                (
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                90
              
              
                )
              
              
    fd
              
                (
              
              
                90
              
              
                )
              
               
    penup
              
                (
              
              
                )
              
              
    seth
              
                (
              
              
                180
              
              
                )
              
              
    fd
              
                (
              
              
                70
              
              
                )
              
              
    pendown
              
                (
              
              
                )
              
              
    seth
              
                (
              
              
                0
              
              
                )
              
              
    fd
              
                (
              
              
                140
              
              
                )
              
              
    seth
              
                (
              
              
                90
              
              
                )
              
              
    penup
              
                (
              
              
                )
              
              
    goto
              
                (
              
              
                -
              
              
                420
              
              
                ,
              
              
                -
              
              
                150
              
              
                )
              
              
    fd
              
                (
              
              
                50
              
              
                )
              
              
    pendown
              
                (
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                90
              
              
                )
              
              
    fd
              
                (
              
              
                140
              
              
                )
              
              
    seth
              
                (
              
              
                0
              
              
                )
              
              
    fd
              
                (
              
              
                5
              
              
                )
              
              
    seth
              
                (
              
              
                70
              
              
                )
              
              
    pensize
              
                (
              
              
                5
              
              
                )
              
              
    goto
              
                (
              
              
                -
              
              
                400
              
              
                ,
              
              
                -
              
              
                100
              
              
                )
              
              
    pensize
              
                (
              
              
                20
              
              
                )
              
              
    seth
              
                (
              
              
                0
              
              
                )
              
              
    fd
              
                (
              
              
                120
              
              
                )
              
              
    angle 
              
                =
              
              
                0
              
              
                for
              
               i 
              
                in
              
              
                range
              
              
                (
              
              
                2
              
              
                )
              
              
                :
              
              
        angle 
              
                -=
              
              
                90
              
              
        seth
              
                (
              
              angle
              
                )
              
              
        fd
              
                (
              
              
                140
              
              
                )
              
              
                def
              
              
                draw_secondname
              
              
                (
              
              
                )
              
              
                :
              
              
    penup
              
                (
              
              
                )
              
              
    goto
              
                (
              
              
                -
              
              
                40
              
              
                ,
              
              
                50
              
              
                )
              
              
    pendown
              
                (
              
              
                )
              
              
    seth
              
                (
              
              
                0
              
              
                )
              
              
    fd
              
                (
              
              
                200
              
              
                )
              
              
    go
              
                (
              
              
                60
              
              
                ,
              
              
                50
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                93
              
              
                )
              
              
    fd
              
                (
              
              
                301
              
              
                )
              
              
    go
              
                (
              
              
                -
              
              
                15
              
              
                ,
              
              
                -
              
              
                100
              
              
                )
              
              
    seth
              
                (
              
              
                0
              
              
                )
              
              
    fd
              
                (
              
              
                150
              
              
                )
              
              
    go
              
                (
              
              
                -
              
              
                70
              
              
                ,
              
              
                -
              
              
                250
              
              
                )
              
              
    fd
              
                (
              
              
                260
              
              
                )
              
              
    penup
              
                (
              
              
                )
              
              
    seth
              
                (
              
              
                140
              
              
                )
              
              
    fd
              
                (
              
              
                130
              
              
                )
              
              
    pendown
              
                (
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                40
              
              
                )
              
              
    fd
              
                (
              
              
                80
              
              
                )
              
              
    pencolor
              
                (
              
              
                "violet"
              
              
                )
              
              
    go
              
                (
              
              
                300
              
              
                ,
              
              
                80
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                65
              
              
                )
              
              
    circle
              
                (
              
              
                -
              
              
                350
              
              
                ,
              
              
                60
              
              
                )
              
              
    pensize
              
                (
              
              
                5
              
              
                )
              
              
    goto
              
                (
              
              
                420
              
              
                ,
              
              
                20
              
              
                )
              
              
    pensize
              
                (
              
              
                20
              
              
                )
              
              
                #go(420,20)
              
              
    seth
              
                (
              
              
                -
              
              
                90
              
              
                )
              
              
    fd
              
                (
              
              
                220
              
              
                )
              
              
    pensize
              
                (
              
              
                5
              
              
                )
              
              
    goto
              
                (
              
              
                540
              
              
                ,
              
              
                100
              
              
                )
              
              
    pensize
              
                (
              
              
                20
              
              
                )
              
              
                #go(540,100)
              
              
    fd
              
                (
              
              
                440
              
              
                )
              
              
                def
              
              
                draw_abb
              
              
                (
              
              
                )
              
              
                :
              
              
    go
              
                (
              
              
                -
              
              
                470
              
              
                ,
              
              
                350
              
              
                )
              
              
                #8A2BE2
              
              
    pencolor
              
                (
              
              
                (
              
              
                138
              
              
                ,
              
              
                43
              
              
                ,
              
              
                226
              
              
                )
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                2
              
              
                )
              
              
    fd
              
                (
              
              
                200
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                135
              
              
                )
              
              
    fd
              
                (
              
              
                250
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                2
              
              
                )
              
              
    fd
              
                (
              
              
                200
              
              
                )
              
              
                #1C86EE
              
              
    pencolor
              
                (
              
              
                (
              
              
                28
              
              
                ,
              
              
                134
              
              
                ,
              
              
                238
              
              
                )
              
              
                )
              
              
    go
              
                (
              
              
                -
              
              
                20
              
              
                ,
              
              
                350
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                45
              
              
                )
              
              
    fd
              
                (
              
              
                100
              
              
                )
              
              
    go
              
                (
              
              
                120
              
              
                ,
              
              
                350
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                135
              
              
                )
              
              
    fd
              
                (
              
              
                100
              
              
                )
              
              
    seth
              
                (
              
              
                -
              
              
                94
              
              
                )
              
              
    fd
              
                (
              
              
                145
              
              
                )
              
              
                #19197A
              
              
    pencolor
              
                (
              
              
                (
              
              
                25
              
              
                ,
              
              
                25
              
              
                ,
              
              
                112
              
              
                )
              
              
                )
              
              
    go
              
                (
              
              
                480
              
              
                ,
              
              
                320
              
              
                )
              
              
    seth
              
                (
              
              
                140
              
              
                )
              
              
    circle
              
                (
              
              
                100
              
              
                ,
              
              
                240
              
              
                )
              
              
setup
              
                (
              
              
                1400
              
              
                ,
              
              
                1400
              
              
                ,
              
              
                0
              
              
                ,
              
              
                0
              
              
                )
              
              
penup
              
                (
              
              
                )
              
              
goto
              
                (
              
              
                -
              
              
                500
              
              
                ,
              
              
                100
              
              
                )
              
              
                #fd(-250)
              
              
pendown
              
                (
              
              
                )
              
              
pensize
              
                (
              
              
                20
              
              
                )
              
              
speed
              
                (
              
              
                0
              
              
                )
              
              
colormode
              
                (
              
              
                255
              
              
                )
              
              
pencolor
              
                (
              
              
                (
              
              
                151
              
              
                ,
              
              
                255
              
              
                ,
              
              
                255
              
              
                )
              
              
                )
              
              

draw_firstname
              
                (
              
              
                )
              
              
pencolor
              
                (
              
              
                "purple"
              
              
                )
              
              

draw_secondname
              
                (
              
              
                )
              
              

draw_abb
              
                (
              
              
                )
              
            
          

更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论