莫愁前路无知己,天下谁人不识君。。。。

python小编程-------趣味绘图1----ball

上一篇 / 下一篇  2017-11-30 17:01:20 / 个人分类:python 小编程

from turtle import *
import turtle
def drawCircle(radius,parts,color1,color2):
    turtle.speed(10)
    turtle.hideturtle()
    p1=pensize()
    p2=pencolor()
    p3=fillcolor()
    pensize(1)
    for part_no in range(parts+1):
        if part_no %2==0:
            pencolor(color1)
            fillcolor(color1)
        else:
            pencolor(color2)
            fillcolor(color2)
        begin_fill()
        seth(part_no*360 / parts)
        fd(radius)
        left(90)
        circle(radius,360 / parts)
        left(90)
        end_fill

        penup()
        setpos(0,0)
        pendown()
    pensize(p1)
    pencolor(p2)
    fillcolor(p3)
drawCircle(160,10,"yellow","black")
drawCircle(150,10,"black","yellow")
drawCircle(110,10,"yellow","black")
drawCircle(100,10,"black","yellow")
penup()
setpos(10,0)
pendown()
pencolor("red")
fillcolor("yellow")
seth(90)
pensize(5)
begin_fill()
circle(10)
end_fill()
turtle.done()

TAG: Python python 绘图

 

评分:0

我来说两句

Open Toolbar