#七段数码管的绘制.py
from turtle import *
from random import *
import time
#绘制单段间隔
def drawGap():
penup()
fd(5)
#绘制单段数码管
def drawLine(draw):
drawGap() #调用drawGap()函数
if draw:
pendown()
else:
penup()
fd(40)
drawGap()
right(90)
#根据数字绘制七段数码管
def drawDigit(digit):
pencolor(random(),random(),random()) #随机获取0-1的颜色
drawLine(True) if digit in [2,3,4,5,6,8,9] else drawLine(False) #调用drawLine()函数
pencolor(random(),random(),random())
drawLine(True) if digit in [0,1,3,4,5,6,7,8,9] else drawLine(False)
pencolor(random(),random(),random())
drawLine(True) if digit in [0,2,3,5,6,8,9] else drawLine(False)
pencolor(random(),random(),random())
drawLine(True) if digit in [0,2,6,8] else drawLine(False)
pencolor(random(),random(),random())
left(90)
drawLine(True) if digit in [0,4,5,6,8,9] else dr
七段数码管的绘制
最新推荐文章于 2024-10-31 10:20:59 发布