RaspiBerry Blog

CnLiutiezhu is here!

python绘图

| 暂无评论

#绘制不同朝向的小乌龟和彩色圆点
from turtle import *
from random import *
import time
speed(9)
getscreen().colormode(255)

def randomcolor():
      red=randint(0,255)
      green=randint(0,255)
      blue=randint(0,255)
      color(red,green,blue)
def randomplace():
      x=randint(-120,120)
      y=randint(-150,150)
      penup()
      goto(x,y)
      pendown

def randomheading():
      setheading(randint(1,360))
def drawcircle():
      dot(randint(1,80))


shape("turtle")
randomcolor()
randomplace()
for i in range(30):
      randomcolor()
      randomplace()
      randomheading()
      stamp()

goto(-150,-200)
write('Waiting a moment...稍等片刻!',72,font="Arial")

time.sleep(3)
clear()
for i in range(30):
      randomcolor()
      randomplace()
      drawcircle()

发表回复

*为必填字段!