import turtle as t
import time
x = 224
y = 345
def set_trutle():
'''
作用:海龟绘图配置项
参数:无
返回:无
'''
t.Screen().colormode(255)
t.setup(width=x, height=y)
t.setworldcoordinates(0,y,x,0)
t.pen()
t.speed(0)
t.delay(0)
t.tracer(5000)
t.pencolor((255,255,255))
t.penup()
def draw_lufei_outline():
'''
作用:绘制路飞轮廓
参数:无
返回:无
'''
f=open("lufei.txt","r")
bigmom_date = f.read().split(" ")
for i in bigmom_date:
try:
j = i.split("_")
x1 = round(float(j[0]))
y1 = round(float(j[1]))
color = j[2][1:-1].split(",")
color[0]=int(color[0])
color[1]=int(color[1])
color[2]=int(color[2])
if((color[0]*0.299 + color[1]*0.587 + color[2]*0.114)>50):
color = (255,255,255);
t.pendown()
t.sety(y1)
t.goto(x1, y1)
t.color(color)
t.penup()
except Exception as e:
print()
f.close()
print("轮廓绘制完成")
def draw_lufei_tintage1():
'''
作用:路飞颜色填充:衣服、帽子
参数:无
返回:无
'''
f=open("lufei.txt","r")
bigmom_date = f.read().split(" ")
for i in bigmom_date:
try:
j = i.split("_")
x1 = int(j[0])
y1 = int(j[1])
color = j[2][1:-1].split(",")
color[0]=int(color[0])
color[1]=int(color[1])
color[2]=int(color[2])
if((color[0]*0.299 + color[1]*0.587 + color[2]*0.114)>150):
color = (255,255,255);
t.pendown()
t.sety(y1)
t.goto(x1, y1)
t.color(color)
t.penup()
except Exception as e:
print()
f.close()
print("上色完成")
def draw_lufei_tintage2():
'''
作用:路飞颜色填充:草帽、腰带
参数:无
返回:无
'''
f=open("lufei.txt","r")
bigmom_date = f.read().split(" ")
for i in bigmom_date:
try:
j = i.split("_")
x1 = int(j[0])
y1 = int(j[1])
color = j[2][1:-1].split(",")
color[0]=int(color[0])
color[1]=int(color[1])
color[2]=int(color[2])
if((color[0]*0.299 + color[1]*0.587 + color[2]*0.114)>215):
color = (255,255,255);
t.pendown()
t.sety(y1)
t.goto(x1, y1)
t.color(color)
t.penup()
except Exception as e:
print()
f.close()
print("上色完成")
set_trutle()
draw_lufei_outline()
draw_lufei_tintage1()
draw_lufei_tintage2()
time.sleep(10000)