情人节,我表白了CSDN小姐姐后,竟然...【为表白写了一个绘图工具,让我不再手残】

情人节,我表白了CSDN小姐姐后,竟然…竟然有人看了这篇文。
以下图片素材由一个还没写完的工具绘制,稍后会放在CSDN的代码仓库(现在能用了,还没时间改,颜色填充算法还没写,有能力的朋友可以修改一下):https://codechina.csdn.net/A757291228/draw_pixel/-/tree/master

无情!竟然告诉我有情人节活动

很快呀,啪的一下又一年情人节又来了,本来我压根记不住的,但是CSDN竟然告诉我有情人节活动。怎么办?这不能忍,那就只能表白CSDN的小姐姐了。你们要不要一起表白?评论区一起表白吧!

表白肯定要写写情书了。结果…一看征文字数要求,竟然600字!你是看不起我吗?
一封情书根本用不到600字,我200字就写完了。为什么才写200字?不要问,问就是是写不出来600字。

我们要表白哪个小姐姐?

这还要想?当然是全都要了!小孩子才做选择。
例如小婷婷、小慧慧,这可都是集美貌、才华于一身的女子。

沉鱼落雁 小婷婷 闭月羞花 小慧慧

小婷婷是谁?小婷婷就是前几天博客之星直播中的主持之一!还记得的弹幕中刷屏的“小婷露脸 流量百万”吗?在CSDN社群中有一个付费专栏群,小婷婷可是付费专栏群中的第一女神。只要小婷婷在线,群里必是最热闹的时候。

那小慧慧又是谁?在微信群中,有一个经常公布信息,到处活跃的运营还记得吗?名字叫做CSDN博客。她就是小慧慧。小慧慧时而性格温柔,时而高冷,就像一个冰雪女王!气质十足!

那怎么样表白这两个小姐姐呢?当然是…写!代!码!生为一个程序直男一定要把这优点发扬光大!

表白CSDN来一幅图~

颜色填充还没写完,不然肯定这图片是漂漂亮亮dev~

一、技术实现(这个工具我本人会不断的迭代更新,包括素材绘制逻辑,因为我要用来画自媒体素材)

毕竟是要画画,首选比较简单的那就是turtle了。但是turtle画东西好麻烦,本身自己就是个手残党,线条都不懂怎么弄。那怎么办?那我们就是用“俄罗斯方块”的画法吧,那就是叠积木~

我们以方块作为线条,进行堆叠就可以完成了。

1.1 完成点绘制

我们先引入turtle库,然后新建一个类,名为core:

from turtle import *class Core:

随后新建一个core类的方法point,作为基本的方块点,作为一个线条的基本单位:

	'''设置'''#填充颜色色值#@fcolor=点填充颜色def fillcolor_set(self,fcolor="black"):fillcolor(fcolor)#笔杆颜色设置#@fcolor=点填充颜色#@pcolor=线颜色def pencolor_set(self,fcolor="black",pcolor="1"):if pcolor=="1":pcolor=fcolorpencolor(pcolor)else:pencolor(pcolor)#笔杆尺寸#@psize=线尺寸def pensize_set(self,psize=1):pensize(psize)#绘制点#@plenght=点长度#@fcolor=点填充颜色#@pcolor=线颜色#@psize=线尺寸def point(self,plenght=10,fcolor="black",pcolor="1",psize=1):poslist=[]self.fillcolor_set(fcolor)self.pencolor_set(fcolor,pcolor)self.pensize_set(psize)begin_fill()for i in range(0,4):poslist.append(pos())fd(plenght)right(90)end_fill()return poslist

point方法默认plenght为10。也就是说基本方块为一个正方形,长宽都为plenght;fcolor为填充的颜色,默认为黑色;pcolor为线条的颜色,其实也就是pen color;psize为相对应的笔的粗细。

在方法中,我们使用poslist记录我们点的每次绘制的位置,这样的话我们在某些时候就可以使用poslist来进行精确定位了。我们再通过fillcolor_set、pencolor_set、pensize_set方法来设置填充色、线条色、现调大小。

在正式绘制方块时开启填充使用begin_fill方法,随后开始绘制一个“点”。这个“点”的绘制也是非常简单,直接循环4次,画出一个矩形即可。并且使用pos方法获取当前的坐标,随后结束绘制“点”后使用end_fill方法进行颜色填充。

这样一个点绘制的方法就完成了。

1.2 完成线段的绘制

点绘制完了接下来我们就需要绘制线了。线从点的基础上进行堆叠,并排排列那就是线。线的方向可以是上下左右,我们可以通过参数传递从而控制线段绘制方向,并且还可以使用对称方法,让我们减少绘制难度。对于对称来说,也有上下左右基于某个中心点的进行的中心对称。
代码如下:

	#step方法的绘图跳转控制#@lenght=总长#@blenght=bit一个位长度#@plenght=点长度#@direction1=横线绘制方向#@direction2=竖线绘制方向#@fcolor=填充颜色#@pcolor=笔颜色#@psize=笔大小#@gotopos=如何跳转pos位置#@cout_i=循环控制变量idef step_control_func_draw_move(self,lenght,blenght,plenght,direction1,direction2,fcolor,pcolor,psize,gotopos1,gotopos2,cout_i,height):print('-----------',blenght)posdict={}posdict['line'+str(cout_i)]=self.line(lenght=blenght,plenght=plenght,direction=direction1,fcolor=fcolor,pcolor=pcolor,psize=psize)self.loc_goto(gotopos1)posdict['vline'+str(cout_i)]=self.line(lenght=height,plenght=plenght,direction=direction2,fcolor=fcolor,pcolor=pcolor,psize=psize)if cout_i!=(lenght-1):self.loc_goto(gotopos2)return posdict#绘制线段#@lenght=线长度#@plenght=点长度#@fcolor=点填充颜色#@pcolor=线颜色#@psize=线尺寸def line(self,lenght=1,plenght=10,direction="right",fcolor="white",pcolor="1",psize=1,symmetrical="f",symmetrical_direction="right"):posdict={}symmetrical_point="f"if symmetrical!="f":if symmetrical_direction=="right":symmetrical_point=pos()+(int(symmetrical)*plenght,0)elif symmetrical_direction=="left":symmetrical_point=pos()+(-int(symmetrical)*plenght,0)elif symmetrical_direction=="up":symmetrical_point=pos()+(0,int(symmetrical)*plenght)elif symmetrical_direction=="down":symmetrical_point=pos()+(0,-int(symmetrical)*plenght)for i in range(0,lenght):posdict['point'+str(i)]=self.point(plenght=plenght,fcolor=fcolor,pcolor=pcolor,psize=psize)self.line_control_func_draw_move(i,direction,lenght,plenght)if symmetrical!="f":self.goto_(symmetrical_point)posdict['symmetrical_point']=self.line(lenght=lenght,plenght=plenght,direction=direction,fcolor=fcolor,pcolor=pcolor,psize=psize,symmetrical="f")self.goto_(posdict['point'+str(lenght-1)][3])return posdict    

以上代码我们主要看line方法。line方法参数plenght为需要传入的点的边长大小,lenght为这个线有多长;direction为需要从哪边开始绘制,从左到右绘制,还是从上到下绘制;symmetrical为对称的位置,symmetrical_direction表示是左右对称,还是右坐对称;symmetrical_direction默认为右,表示左边的绘制线段,将会镜像到左侧,若symmetrical为10,那么对称位置就是10*边长大小为对称位置。

我们接下来看line方法中的代码,其中symmetrical_point默认为f,若symmetrical传入参数则表示有对称需求,这时将会通过传入对称位置从而计算x与y的坐标:

symmetrical_point="f"if symmetrical!="f":if symmetrical_direction=="right":symmetrical_point=pos()+(int(symmetrical)*plenght,0)elif symmetrical_direction=="left":symmetrical_point=pos()+(-int(symmetrical)*plenght,0)elif symmetrical_direction=="up":symmetrical_point=pos()+(0,int(symmetrical)*plenght)elif symmetrical_direction=="down":symmetrical_point=pos()+(0,-int(symmetrical)*plenght)

其中左右对称,那么就是左右两边x的正负,如果是上下对称则需要对y进行操作,上对称y则正,下对称则y负。随后我们开始进行循环点的个数,多长就循环多少次:

for i in range(0,lenght):posdict['point'+str(i)]=self.point(plenght=plenght,fcolor=fcolor,pcolor=pcolor,psize=psize)self.line_control_func_draw_move(i,direction,lenght,plenght)

以上代码主要查看line_control_func_draw_move方法。line_control_func_draw_move作为控制线段绘制的方法,而point就直接绘制出一个点,如何使绘制开始位置进行控制,就需要查看line_control_func_draw_move:

def line_control_func_draw_move(self,cout_i,direction,lenght,plenght):if cout_i!=(lenght-1):if direction=="right":self.loc_goto((plenght,0))elif direction=="left":self.loc_goto((-plenght,0))elif direction=="up":self.loc_goto((0,plenght))elif direction=="down":self.loc_goto((0,-plenght))elif cout_i==(lenght-1):if direction=="left":self.loc_goto((plenght,0))if direction=="up":self.loc_goto((0,-plenght))

line_control_func_draw_move中,如果是从左往右绘制,只需要通过loc_goto方法直接跳转到当前位置增加1个基本单位plenght处即可完成下一个绘制位置的控制,loc_goto方法如下:

	#跳转def loc_goto(self,movepos):penup()goto(pos()+movepos)pendown()

最后,我们查看对称线段的如何绘制,代码如下:

if symmetrical!="f":self.goto_(symmetrical_point)posdict['symmetrical_point']=self.line(lenght=lenght,plenght=plenght,direction=direction,fcolor=fcolor,pcolor=pcolor,psize=psize,symmetrical="f")self.goto_(posdict['point'+str(lenght-1)][3])

其实对称线段绘制就很简单了,直接传入需要从哪个点开始绘制,随后调用line方法就可以了,这个时候关闭对称参数即可。

1.3 完成阶梯的绘制

在方块堆叠的实现的内容中,绘制出来的效果更像是马赛克风格的图像,那么阶梯的绘制是较为常见的。代码如下:

	#step方法的绘图跳转控制#@lenght=总长#@blenght=bit一个位长度#@plenght=点长度#@direction1=横线绘制方向#@direction2=竖线绘制方向#@fcolor=填充颜色#@pcolor=笔颜色#@psize=笔大小#@gotopos=如何跳转pos位置#@cout_i=循环控制变量idef step_control_func_draw_move(self,lenght,blenght,plenght,direction1,direction2,fcolor,pcolor,psize,gotopos1,gotopos2,cout_i,height):print('-----------',blenght)posdict={}posdict['line'+str(cout_i)]=self.line(lenght=blenght,plenght=plenght,direction=direction1,fcolor=fcolor,pcolor=pcolor,psize=psize)self.loc_goto(gotopos1)posdict['vline'+str(cout_i)]=self.line(lenght=height,plenght=plenght,direction=direction2,fcolor=fcolor,pcolor=pcolor,psize=psize)if cout_i!=(lenght-1):self.loc_goto(gotopos2)return posdict#绘制线段#@lenght=线长度#@height=线高度#@blenght=bit一个位长度#@plenght=点长度#@fcolor=点填充颜色#@pcolor=线颜色#@psize=线尺寸def step(self,lenght=1,height=1,blenght=1,plenght=10,direction="right",fcolor="black",pcolor="1",psize=1,symmetrical="f",symmetrical_direction="right"):posdict={}symmetrical_point="f"symmetrical_draw_direction=''if symmetrical!="f":if symmetrical_direction=="right":symmetrical_point=pos()+(int(symmetrical)*plenght,0)if direction=="right":symmetrical_draw_direction="left"elif direction=="left":symmetrical_draw_direction="right"elif direction=="rightdown":symmetrical_draw_direction="leftdown"elif direction=="leftdown":symmetrical_draw_direction="rightdown"elif symmetrical_direction=="left":symmetrical_point=pos()+(-int(symmetrical)*plenght,0)if direction=="right":symmetrical_draw_direction="left"elif direction=="left":symmetrical_draw_direction="right"elif direction=="rightdown":symmetrical_draw_direction="leftdown"elif direction=="leftdown":symmetrical_draw_direction="rightdown"elif symmetrical_direction=="rightdown":symmetrical_point=pos()+(0,int(symmetrical)*plenght)if direction=="right":symmetrical_draw_direction="left"elif direction=="left":symmetrical_draw_direction="right"elif direction=="rightdown":symmetrical_draw_direction="leftdown"elif direction=="leftdown":symmetrical_draw_direction="rightdown"elif symmetrical_direction=="leftdown":symmetrical_point=pos()+(0,-int(symmetrical)*plenght)if direction=="right":symmetrical_draw_direction="left"elif direction=="left":symmetrical_draw_direction="right"elif direction=="rightdown":symmetrical_draw_direction="leftdown"elif direction=="leftdown":symmetrical_draw_direction="rightdown"for i in range(0,lenght):if direction=="right":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,direction,"up",fcolor,pcolor,psize,(plenght,plenght),(plenght,plenght*2),i,height)elif direction=="left":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,"left","up",fcolor,pcolor,psize,(-plenght*2,plenght),(-plenght,plenght*2),i,height)elif direction=="rightdown":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,"right","down",fcolor,pcolor,psize,(plenght,-plenght),(plenght,-plenght),i,height)elif direction=="leftdown":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,"left","down",fcolor,pcolor,psize,(-plenght*2,-plenght),(-plenght,-plenght),i,height)#对称if symmetrical!="f":self.goto_(symmetrical_point)posdict['symmetrical_step']=self.step(lenght=lenght,height=height,blenght=blenght,plenght=plenght,direction=symmetrical_draw_direction,fcolor=fcolor,pcolor=pcolor,psize=psize)print(posdict)self.goto_(posdict['step'+str(lenght-1)]['vline'+str(lenght-1)]['point'+str(height-1)][0])return posdict

其实阶梯的绘制方法跟线段原理是一致的。首先看一下绘制控制:

for i in range(0,lenght):if direction=="right":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,direction,"up",fcolor,pcolor,psize,(plenght,plenght),(plenght,plenght*2),i,height)elif direction=="left":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,"left","up",fcolor,pcolor,psize,(-plenght*2,plenght),(-plenght,plenght*2),i,height)elif direction=="rightdown":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,"right","down",fcolor,pcolor,psize,(plenght,-plenght),(plenght,-plenght),i,height)elif direction=="leftdown":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,"left","down",fcolor,pcolor,psize,(-plenght*2,-plenght),(-plenght,-plenght),i,height)

阶梯的绘制方向我们有左上、左下、右上和右下,这个时候直接判断绘制内容,随后使用控制方法控制即可:

	#step方法的绘图跳转控制#@lenght=总长#@blenght=bit一个位长度#@plenght=点长度#@direction1=横线绘制方向#@direction2=竖线绘制方向#@fcolor=填充颜色#@pcolor=笔颜色#@psize=笔大小#@gotopos=如何跳转pos位置#@cout_i=循环控制变量idef step_control_func_draw_move(self,lenght,blenght,plenght,direction1,direction2,fcolor,pcolor,psize,gotopos1,gotopos2,cout_i,height):print('-----------',blenght)posdict={}posdict['line'+str(cout_i)]=self.line(lenght=blenght,plenght=plenght,direction=direction1,fcolor=fcolor,pcolor=pcolor,psize=psize)self.loc_goto(gotopos1)posdict['vline'+str(cout_i)]=self.line(lenght=height,plenght=plenght,direction=direction2,fcolor=fcolor,pcolor=pcolor,psize=psize)if cout_i!=(lenght-1):self.loc_goto(gotopos2)return posdict

控制方法此时就不像线段那样只移动一个坐标位置,阶梯需要x和y坐标都进行增删才可以实现,同理可得就不再赘述内容了。

1.4完整的core类代码

至此,完整的core类基本代码就已经写完了,代码如下:

from turtle import *class Core:'''设置'''#填充颜色色值#@fcolor=点填充颜色def fillcolor_set(self,fcolor="black"):fillcolor(fcolor)#笔杆颜色设置#@fcolor=点填充颜色#@pcolor=线颜色def pencolor_set(self,fcolor="black",pcolor="1"):if pcolor=="1":pcolor=fcolorpencolor(pcolor)else:pencolor(pcolor)#笔杆尺寸#@psize=线尺寸def pensize_set(self,psize=1):pensize(psize)'''other func '''#跳转def loc_goto(self,movepos):penup()goto(pos()+movepos)pendown()def goto_(self,pos_):penup()goto(pos_)pendown()#line方法的绘图跳转控制def line_control_func_draw_move(self,cout_i,direction,lenght,plenght):if cout_i!=(lenght-1):if direction=="right":self.loc_goto((plenght,0))elif direction=="left":self.loc_goto((-plenght,0))elif direction=="up":self.loc_goto((0,plenght))elif direction=="down":self.loc_goto((0,-plenght))elif cout_i==(lenght-1):if direction=="left":self.loc_goto((plenght,0))if direction=="up":self.loc_goto((0,-plenght))#step方法的绘图跳转控制#@lenght=总长#@blenght=bit一个位长度#@plenght=点长度#@direction1=横线绘制方向#@direction2=竖线绘制方向#@fcolor=填充颜色#@pcolor=笔颜色#@psize=笔大小#@gotopos=如何跳转pos位置#@cout_i=循环控制变量idef step_control_func_draw_move(self,lenght,blenght,plenght,direction1,direction2,fcolor,pcolor,psize,gotopos1,gotopos2,cout_i,height):print('-----------',blenght)posdict={}posdict['line'+str(cout_i)]=self.line(lenght=blenght,plenght=plenght,direction=direction1,fcolor=fcolor,pcolor=pcolor,psize=psize)self.loc_goto(gotopos1)posdict['vline'+str(cout_i)]=self.line(lenght=height,plenght=plenght,direction=direction2,fcolor=fcolor,pcolor=pcolor,psize=psize)if cout_i!=(lenght-1):self.loc_goto(gotopos2)return posdict'''绘制'''#绘制点#@plenght=点长度#@fcolor=点填充颜色#@pcolor=线颜色#@psize=线尺寸def point(self,plenght=10,fcolor="black",pcolor="1",psize=1):poslist=[]self.fillcolor_set(fcolor)self.pencolor_set(fcolor,pcolor)self.pensize_set(psize)begin_fill()for i in range(0,4):poslist.append(pos())fd(plenght)right(90)end_fill()return poslist#绘制线段#@lenght=线长度#@plenght=点长度#@fcolor=点填充颜色#@pcolor=线颜色#@psize=线尺寸def line(self,lenght=1,plenght=10,direction="right",fcolor="white",pcolor="1",psize=1,symmetrical="f",symmetrical_direction="right"):posdict={}symmetrical_point="f"if symmetrical!="f":if symmetrical_direction=="right":symmetrical_point=pos()+(int(symmetrical)*plenght,0)elif symmetrical_direction=="left":symmetrical_point=pos()+(-int(symmetrical)*plenght,0)elif symmetrical_direction=="up":symmetrical_point=pos()+(0,int(symmetrical)*plenght)elif symmetrical_direction=="down":symmetrical_point=pos()+(0,-int(symmetrical)*plenght)for i in range(0,lenght):posdict['point'+str(i)]=self.point(plenght=plenght,fcolor=fcolor,pcolor=pcolor,psize=psize)self.line_control_func_draw_move(i,direction,lenght,plenght)if symmetrical!="f":self.goto_(symmetrical_point)posdict['symmetrical_point']=self.line(lenght=lenght,plenght=plenght,direction=direction,fcolor=fcolor,pcolor=pcolor,psize=psize,symmetrical="f")self.goto_(posdict['point'+str(lenght-1)][3])return posdict    #绘制线段#@lenght=线长度#@height=线高度#@blenght=bit一个位长度#@plenght=点长度#@fcolor=点填充颜色#@pcolor=线颜色#@psize=线尺寸def step(self,lenght=1,height=1,blenght=1,plenght=10,direction="right",fcolor="black",pcolor="1",psize=1,symmetrical="f",symmetrical_direction="right"):posdict={}symmetrical_point="f"symmetrical_draw_direction=''if symmetrical!="f":if symmetrical_direction=="right":symmetrical_point=pos()+(int(symmetrical)*plenght,0)if direction=="right":symmetrical_draw_direction="left"elif direction=="left":symmetrical_draw_direction="right"elif direction=="rightdown":symmetrical_draw_direction="leftdown"elif direction=="leftdown":symmetrical_draw_direction="rightdown"elif symmetrical_direction=="left":symmetrical_point=pos()+(-int(symmetrical)*plenght,0)if direction=="right":symmetrical_draw_direction="left"elif direction=="left":symmetrical_draw_direction="right"elif direction=="rightdown":symmetrical_draw_direction="leftdown"elif direction=="leftdown":symmetrical_draw_direction="rightdown"elif symmetrical_direction=="rightdown":symmetrical_point=pos()+(0,int(symmetrical)*plenght)if direction=="right":symmetrical_draw_direction="left"elif direction=="left":symmetrical_draw_direction="right"elif direction=="rightdown":symmetrical_draw_direction="leftdown"elif direction=="leftdown":symmetrical_draw_direction="rightdown"elif symmetrical_direction=="leftdown":symmetrical_point=pos()+(0,-int(symmetrical)*plenght)if direction=="right":symmetrical_draw_direction="left"elif direction=="left":symmetrical_draw_direction="right"elif direction=="rightdown":symmetrical_draw_direction="leftdown"elif direction=="leftdown":symmetrical_draw_direction="rightdown"for i in range(0,lenght):if direction=="right":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,direction,"up",fcolor,pcolor,psize,(plenght,plenght),(plenght,plenght*2),i,height)elif direction=="left":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,"left","up",fcolor,pcolor,psize,(-plenght*2,plenght),(-plenght,plenght*2),i,height)elif direction=="rightdown":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,"right","down",fcolor,pcolor,psize,(plenght,-plenght),(plenght,-plenght),i,height)elif direction=="leftdown":posdict["step"+str(i)]=self.step_control_func_draw_move(lenght,blenght,plenght,"left","down",fcolor,pcolor,psize,(-plenght*2,-plenght),(-plenght,-plenght),i,height)#对称if symmetrical!="f":self.goto_(symmetrical_point)posdict['symmetrical_step']=self.step(lenght=lenght,height=height,blenght=blenght,plenght=plenght,direction=symmetrical_draw_direction,fcolor=fcolor,pcolor=pcolor,psize=psize)print(posdict)self.goto_(posdict['step'+str(lenght-1)]['vline'+str(lenght-1)]['point'+str(height-1)][0])return posdict

1.5再次封装,逻辑绘图

但是我们的绘制方法需要自己敲代码,是不是觉得很麻烦?我们那么懒,那么就再写个方法封装一下,让我们直接使用比较轻松的方式进行线段绘制吧。新建一个文件,叫做drawTools,引入core类以及turtle:

from core import Core
from turtle import *

我们新建一个类,继承Core,叫做Tools:

class Tools(Core):

我们甚至可以直接做辅助线,如何做?很简单,画格子就可以了,直接把辅助线的绘制方法写在init方法中吧:

width,height=0,0def __init__(self,open=False,helperline='red'):width=window_width()height=window_height()#行列lines=int(height/10)rows=int(width/10)#左上角leftx=-int(width/2)topy=int(height/2)self.goto_((leftx,topy))if open==True:for l in range(lines):nowpos=pos()-(0,0)self.line(rows,10,pcolor=helperline)topy-=10self.goto_((leftx,topy))qx,qy=-160,160self.goto_((qx,qy))for l in range(32):nowpos=pos()-(0,0)self.line(32,10,pcolor="blue")qy-=10self.goto_((qx,qy))qx,qy=-80,80self.goto_((qx,qy))for l in range(16):nowpos=pos()-(0,0)self.line(16,10,pcolor="green")qy-=10self.goto_((qx,qy))qx,qy=-20,20self.goto_((qx,qy))for l in range(4):nowpos=pos()-(0,0)self.line(4,10,pcolor="red")qy-=10self.goto_((qx,qy))self.goto_((0,0))

init接收2个参数,一个是open,决定是否开启辅助线,helperline则是辅助线的颜色。
我们首先需要获取整个canvas画布的长宽,以及我们辅助线可以有多长,还有就是左上角绘制起始点的位置,随后跳到该位置准备进行绘制:

		width=window_width()height=window_height()#行列lines=int(height/10)rows=int(width/10)#左上角leftx=-int(width/2)topy=int(height/2)self.goto_((leftx,topy))

随后就是简单的代码进行画格子了,为了比较清晰,我们可以分别用不同颜色进行区分:

if open==True:for l in range(lines):nowpos=pos()-(0,0)self.line(rows,10,pcolor=helperline)topy-=10self.goto_((leftx,topy))qx,qy=-160,160self.goto_((qx,qy))for l in range(32):nowpos=pos()-(0,0)self.line(32,10,pcolor="blue")qy-=10self.goto_((qx,qy))qx,qy=-80,80self.goto_((qx,qy))for l in range(16):nowpos=pos()-(0,0)self.line(16,10,pcolor="green")qy-=10self.goto_((qx,qy))qx,qy=-20,20self.goto_((qx,qy))for l in range(4):nowpos=pos()-(0,0)self.line(4,10,pcolor="red")qy-=10self.goto_((qx,qy))self.goto_((0,0))

以上代码中的qx,qy则是到达该区域后进行的不同颜色的绘制,代码没有优化,所以就将就着看着吧。(可以用我就懒了,哈哈哈)最后跳转到0,0中心点。

那么接下来我们需要使用比较简单的方式进行绘制内容了。新建一个方法叫做drawlines:

#绘制线段 'length:2;direction:down;fcolor:black;pos:(0,-100);symmetrical:13'def drawlines(self,drawcon=[],startpos=(0,0)):for c in drawcon:c_val=c.split(';')length=0direction=''fcolor=''posv=Nonesymmetrical='f'symmetrical_direction="right"line_type='line'for v in c_val:demens=v.split(':')if demens[0]=='length':length=int(demens[1])elif demens[0]=='direction':direction=demens[1]elif demens[0]=='fcolor':fcolor=demens[1]elif demens[0]=='pos':posval=demens[1].split(',')posv=(int(posval[0])+startpos[0],int(posval[1])+startpos[1])elif demens[0]=='symmetrical':symmetrical=int(demens[1])elif demens[0]=='symmetrical_direction':symmetrical_direction=demens[1]elif demens[0]=='line_type':line_type=demens[1]self.goto_(posv)if line_type=='line':self.line(length,fcolor=fcolor,direction=direction,symmetrical=symmetrical,symmetrical_direction=symmetrical_direction)

接收参数drawcon为一个列表,列表里面包含了绘制逻辑,绘制逻辑示例为:length:2;direction:down;fcolor:black;pos:(0,-100);symmetrical:13,length表示长度多少,direction表示从绘制点往下画还是往左、往右、往上画,fcolor为填充颜色yay,pos为其实绘制点,symmetrical表示对称位置,默认对称为右对称镜像。
我们的命令是使用分号进行分隔,由于我们的一张图片不止一条线段,所以我们直接使用循环遍历列表的内容。遍历内容时,使用split分隔字符即可。

for c in drawcon:c_val=c.split(';')length=0direction=''fcolor=''posv=Nonesymmetrical='f'symmetrical_direction="right"line_type='line'

以上一些变量是作为局部变量方便接下来使用而已,用法基础,内容就不再赘述了。随后使用分号进行分隔后得到一组一组的数据,例如length:2、direction:down…他们之间使用的是冒号进行分隔,那么再遍历内容,进行冒号分隔即可。这个时候获取他们的第0维度的文本就可以知道是什么数据了,随后使用局部变量赋值,最后传入到line方法中,这样的话就可以通过字符串形式调用lline方法了,而且及其简单:

for v in c_val:demens=v.split(':')if demens[0]=='length':length=int(demens[1])elif demens[0]=='direction':direction=demens[1]elif demens[0]=='fcolor':fcolor=demens[1]elif demens[0]=='pos':posval=demens[1].split(',')posv=(int(posval[0])+startpos[0],int(posval[1])+startpos[1])elif demens[0]=='symmetrical':symmetrical=int(demens[1])elif demens[0]=='symmetrical_direction':symmetrical_direction=demens[1]elif demens[0]=='line_type':line_type=demens[1]self.goto_(posv)if line_type=='line':self.line(length,fcolor=fcolor,direction=direction,symmetrical=symmetrical,symmetrical_direction=symmetrical_direction)

1.6完整的逻辑绘图类代码

这个时候再次封装将会使我们的代码变得十分简单。完整的代码如下:

from core import Core
from turtle import *class Tools(Core):width,height=0,0def __init__(self,open=False,helperline='red'):width=window_width()height=window_height()#行列lines=int(height/10)rows=int(width/10)#左上角leftx=-int(width/2)topy=int(height/2)self.goto_((leftx,topy))if open==True:for l in range(lines):nowpos=pos()-(0,0)self.line(rows,10,pcolor=helperline)topy-=10self.goto_((leftx,topy))qx,qy=-160,160self.goto_((qx,qy))for l in range(32):nowpos=pos()-(0,0)self.line(32,10,pcolor="blue")qy-=10self.goto_((qx,qy))qx,qy=-80,80self.goto_((qx,qy))for l in range(16):nowpos=pos()-(0,0)self.line(16,10,pcolor="green")qy-=10self.goto_((qx,qy))qx,qy=-20,20self.goto_((qx,qy))for l in range(4):nowpos=pos()-(0,0)self.line(4,10,pcolor="red")qy-=10self.goto_((qx,qy))self.goto_((0,0))#绘制线段 'length:2;direction:down;fcolor:black;pos:(0,-100);symmetrical:13'def drawlines(self,drawcon=[],startpos=(0,0)):for c in drawcon:c_val=c.split(';')length=0direction=''fcolor=''posv=Nonesymmetrical='f'symmetrical_direction="right"line_type='line'for v in c_val:demens=v.split(':')if demens[0]=='length':length=int(demens[1])elif demens[0]=='direction':direction=demens[1]elif demens[0]=='fcolor':fcolor=demens[1]elif demens[0]=='pos':posval=demens[1].split(',')posv=(int(posval[0])+startpos[0],int(posval[1])+startpos[1])elif demens[0]=='symmetrical':symmetrical=int(demens[1])elif demens[0]=='symmetrical_direction':symmetrical_direction=demens[1]elif demens[0]=='line_type':line_type=demens[1]self.goto_(posv)if line_type=='line':self.line(length,fcolor=fcolor,direction=direction,symmetrical=symmetrical,symmetrical_direction=symmetrical_direction)

1.7 实例

现在我想画个狗头,只需要编写出绘制逻辑,如下:

#dog face
dog_face=[#耳朵'length:9;direction:down;fcolor:black;pos:0,0;symmetrical:20;','length:2;direction:right;fcolor:black;pos:10,10;symmetrical:17;','length:1;direction:right;fcolor:black;pos:30,0;symmetrical:14;','length:1;direction:right;fcolor:black;pos:40,-10;symmetrical:12;','length:11;direction:right;fcolor:black;pos:50,-20;','length:1;direction:right;fcolor:black;pos:40,-30;symmetrical:12;','length:2;direction:down;fcolor:black;pos:30,-40;symmetrical:14;','length:2;direction:right;fcolor:black;pos:10,-60;symmetrical:17;',#脸蛋'length:7;direction:down;fcolor:black;pos:-10,-90;symmetrical:22;','length:2;direction:down;fcolor:black;pos:0,-160;symmetrical:20;','length:2;direction:right;fcolor:black;pos:10,-180;symmetrical:17;','length:2;direction:down;fcolor:black;pos:30,-190;symmetrical:14;','length:1;direction:down;fcolor:black;pos:40,-210;','length:2;direction:right;fcolor:black;pos:150,-210;','length:10;direction:right;fcolor:black;pos:50,-220;',#眼眶'length:2;direction:down;fcolor:black;pos:0,-110;symmetrical:12;','length:6;direction:right;fcolor:black;pos:10,-100;symmetrical:12;','length:2;direction:down;fcolor:black;pos:70,-110;symmetrical:12;','length:6;direction:right;fcolor:black;pos:10,-130;symmetrical:12;',#眼珠'length:2;direction:down;fcolor:black;pos:60,-110;symmetrical:12;','length:1;direction:down;fcolor:gray;pos:50,-110;symmetrical:12;','length:1;direction:down;fcolor:black;pos:50,-120;symmetrical:12;',#鼻子嘴巴'length:2;direction:down;fcolor:black;pos:70,-150;symmetrical:2;','length:5;direction:down;fcolor:black;pos:80,-150;','length:7;direction:right;fcolor:black;pos:60,-200;','length:1;direction:right;fcolor:black;pos:130,-190;','length:1;direction:right;fcolor:black;pos:140,-180;',
]

然后引入库:

from drawTools import Tools
from turtle import *

调用工具即可:

tool=Tools()
tracer(5,1)tool.drawlines(zan)

狗头就完成了:

再画个程序员吧:

逻辑如下:

#programer
programer=[#头发'length:3;direction:right;fcolor:black;pos:0,0;','length:11;direction:right;fcolor:black;pos:30,10;','length:2;direction:right;fcolor:black;pos:140,0;','length:1;direction:right;fcolor:black;pos:160,-10;','length:3;direction:right;fcolor:black;pos:170,-20;','length:4;direction:down;fcolor:black;pos:200,-30;','length:2;direction:left;fcolor:black;pos:190,-70;','length:2;direction:left;fcolor:black;pos:170,-80;','length:5;direction:up;fcolor:black;pos:150,-70;','length:2;direction:up;fcolor:black;pos:140,-70;','length:3;direction:left;fcolor:black;pos:140,-70;','length:3;direction:left;fcolor:black;pos:110,-80;','length:1;direction:left;fcolor:black;pos:80,-70;','length:2;direction:left;fcolor:black;pos:70,-80;','length:1;direction:left;fcolor:black;pos:50,-70;','length:3;direction:down;fcolor:black;pos:40,-60;','length:4;direction:left;fcolor:black;pos:30,-80;','length:5;direction:down;fcolor:black;pos:-10,-80;',#左侧脸最左侧坐标'length:2;direction:up;fcolor:black;pos:-20,-110;','length:8;direction:up;fcolor:black;pos:-30,-100;','length:1;direction:up;fcolor:black;pos:-20,-20;','length:1;direction:up;fcolor:black;pos:-10,-10;',#脸廓'length:2;direction:down;fcolor:black;pos:0,-130;','length:6;direction:down;fcolor:black;pos:10,-150;','length:1;direction:down;fcolor:black;pos:20,-210;','length:12;direction:right;fcolor:black;pos:30,-220;','length:1;direction:right;fcolor:black;pos:150,-210;','length:1;direction:right;fcolor:black;pos:160,-200;','length:11;direction:up;fcolor:black;pos:170,-190;',#眼睛'length:4;direction:right;fcolor:black;pos:40,-105;symmetrical:8;',#眉毛'length:2;direction:down;fcolor:black;pos:70,-125;symmetrical:5;',#嘴巴'length:2;direction:down;fcolor:black;pos:50,-175;symmetrical:8;','length:2;direction:down;fcolor:black;pos:50,-175;symmetrical:8;','length:7;direction:right;fcolor:black;pos:60,-195;',
]

再点个赞:

逻辑:

#赞
zan=[#袖子'length:6;direction:down;fcolor:black;pos:0,0;symmetrical:3;',    'length:4;direction:right;fcolor:black;pos:0,10;symmetrical:7;symmetrical_direction:down;', #拇指'length:1;direction:down;fcolor:black;pos:40,10;','length:1;direction:down;fcolor:black;pos:50,20;symmetrical:4;','length:1;direction:down;fcolor:black;pos:60,30;','length:3;direction:up;fcolor:black;pos:70,40;','length:1;direction:up;fcolor:black;pos:80,70;symmetrical:2;','length:2;direction:right;fcolor:black;pos:90,80;','length:6;direction:down;fcolor:black;pos:100,80;',#握拳'length:6;direction:right;fcolor:black;pos:80,10;','length:6;direction:down;fcolor:black;pos:140,10;','length:1;direction:down;fcolor:black;pos:130,-50;','length:9;direction:left;fcolor:black;pos:120,-60;',
]

当然还有更多的逻辑代码如下:

drawcon=['length:4;direction:down;fcolor:black;pos:0,0','length:6;direction:down;fcolor:black;pos:-10,-40','length:2;direction:down;fcolor:black;pos:0,-100;symmetrical:13','length:2;direction:right;fcolor:black;pos:10,-120;symmetrical:10','length:8;direction:right;fcolor:black;pos:30,-130','length:8;direction:down;fcolor:black;pos:140,-20','length:2;direction:down;fcolor:black;pos:130,0','length:3;direction:right;fcolor:black;pos:100,10','length:2;direction:down;fcolor:black;pos:90,0','length:5;direction:left;fcolor:black;pos:90,-20','length:2;direction:up;fcolor:black;pos:40,-20','length:3;direction:left;fcolor:black;pos:30,0','length:1;direction:left;fcolor:black;pos:0,-60;symmetrical:13','length:1;direction:down;fcolor:black;pos:0,-80;symmetrical:13','length:2;direction:down;fcolor:black;pos:30,-70;symmetrical:7','length:2;direction:right;fcolor:black;pos:60,-90',]drawcon1=['length:1;direction:down;fcolor:black;pos:0,0','length:3;direction:down;fcolor:black;pos:-10,-10','length:2;direction:right;fcolor:black;pos:0,-40','length:2;direction:right;fcolor:black;pos:10,-20','length:1;direction:right;fcolor:black;pos:20,-30','length:1;direction:right;fcolor:black;pos:20,-30','length:2;direction:right;fcolor:black;pos:30,-40','length:1;direction:right;fcolor:black;pos:40,-50','length:2;direction:right;fcolor:black;pos:50,-60','length:1;direction:right;fcolor:black;pos:70,-50','length:3;direction:up;fcolor:black;pos:80,-40','length:2;direction:left;fcolor:black;pos:70,-10','length:2;direction:down;fcolor:black;pos:50,-20','length:2;direction:left;fcolor:black;pos:40,-10','length:2;direction:up;fcolor:black;pos:20,0','length:1;direction:left;fcolor:black;pos:10,10',]human_head=['length:26;direction:right;fcolor:black;pos:0,0;symmetrical:21;symmetrical_direction:down','length:21;direction:down;fcolor:black;pos:0,0;symmetrical:25;','length:7;direction:right;fcolor:black;pos:20,-85;symmetrical:14;','length:1;direction:down;fcolor:black;pos:120,-152;symmetrical:2;symmetrical_direction:down;','length:1;direction:down;fcolor:black;pos:110,-162;symmetrical:2;symmetrical_direction:down;','length:3;direction:right;fcolor:black;pos:120,-192;',
]web=['length:32;direction:right;fcolor:black;pos:0,0;symmetrical:21;symmetrical_direction:down', 'length:21;direction:down;fcolor:black;pos:0,0;symmetrical:31;','length:4;direction:down;fcolor:black;pos:160,-210;','length:17;direction:right;fcolor:black;pos:80,-250;','length:6;direction:right;fcolor:blue;pos:20,-50;','length:6;direction:right;fcolor:blue;pos:50,-70;',
]phone=['length:16;direction:right;fcolor:black;pos:0,0;symmetrical:20;symmetrical_direction:down', 'length:20;direction:down;fcolor:black;pos:0,0;symmetrical:15;','length:16;direction:right;fcolor:black;pos:0,-170;','length:1;direction:right;fcolor:black;pos:75,-185;',
]spider=['length:17;direction:right;fcolor:black;pos:0,0;symmetrical:11;symmetrical_direction:down','length:11;direction:down;fcolor:black;pos:0,0;symmetrical:16;','length:6;direction:right;fcolor:black;pos:20,-20;symmetrical:6;symmetrical_direction:down','length:6;direction:down;fcolor:black;pos:20,-20;symmetrical:5;','length:6;direction:right;fcolor:black;pos:90,-20;symmetrical:6;symmetrical_direction:down','length:6;direction:down;fcolor:black;pos:90,-20;symmetrical:5;','length:2;direction:right;fcolor:black;pos:40,-40;symmetrical:7;','length:2;direction:right;fcolor:black;pos:40,-50;symmetrical:7;','length:6;direction:left;fcolor:black;pos:0,-20;symmetrical:22;',#第一根腿'length:3;direction:down;fcolor:black;pos:-60,-20;symmetrical:28;','length:7;direction:left;fcolor:black;pos:0,-60;symmetrical:23;',#中间腿'length:8;direction:left;fcolor:black;pos:0,-80;symmetrical:24;',#最前面的腿'length:4;direction:down;fcolor:black;pos:-80,-80;symmetrical:32;',
]camera=['length:26;direction:right;fcolor:black;pos:0,0;symmetrical:14;symmetrical_direction:down','length:14;direction:down;fcolor:black;pos:0,0;symmetrical:25;','length:6;direction:right;fcolor:black;pos:20,-30;symmetrical:4;symmetrical_direction:down','length:4;direction:down;fcolor:black;pos:20,-30;symmetrical:5;','length:3;direction:right;fcolor:black;pos:200,-20;',
]led=['length:8;direction:right;fcolor:black;pos:0,0','length:1;direction:right;fcolor:black;pos:-10,-10;symmetrical:9;','length:9;direction:down;fcolor:black;pos:-20,-20;symmetrical:11;','length:1;direction:down;fcolor:black;pos:-10,-110;symmetrical:9;','length:1;direction:down;fcolor:black;pos:0,-120;symmetrical:7;','length:1;direction:down;fcolor:black;pos:10,-130;symmetrical:5;','length:4;direction:right;fcolor:black;pos:20,-150;symmetrical:2;symmetrical_direction:down',#灯座'length:2;direction:up;fcolor:black;pos:0,20',#灯光'length:2;direction:up;fcolor:black;pos:20,20','length:2;direction:up;fcolor:black;pos:40,20','length:2;direction:up;fcolor:black;pos:60,20','length:2;direction:up;fcolor:black;pos:80,20',]#----------------------------
#哭脸
cry_face=['length:26;direction:right;fcolor:black;pos:0,0;symmetrical:21;symmetrical_direction:down','length:21;direction:down;fcolor:black;pos:0,0;symmetrical:25;','length:7;direction:right;fcolor:black;pos:20,-85;symmetrical:14;','length:12;direction:down;fcolor:black;pos:20,-105;symmetrical:14;','length:12;direction:down;fcolor:black;pos:80,-105;symmetrical:14;','length:5;direction:right;fcolor:black;pos:100,-145;',
]#苹果
apple=['length:2;direction:right;fcolor:black;pos:0,0;symmetrical:10;symmetrical_direction:down','length:1;direction:right;fcolor:black;pos:20,-10;symmetrical:8;symmetrical_direction:down',#苹果凹坑'length:3;direction:right;fcolor:black;pos:30,0;symmetrical:10;symmetrical_direction:down','length:1;direction:right;fcolor:black;pos:-10,-10;symmetrical:8;symmetrical_direction:down','length:1;direction:right;fcolor:black;pos:-20,-20;symmetrical:6;symmetrical_direction:down','length:5;direction:down;fcolor:black;pos:-30,-30;','length:1;direction:right;fcolor:black;pos:60,-10;symmetrical:8;symmetrical_direction:down',#咬痕'length:1;direction:right;fcolor:black;pos:50,-20;symmetrical:6;symmetrical_direction:down','length:1;direction:left;fcolor:black;pos:40,-30;symmetrical:4;symmetrical_direction:down','length:3;direction:down;fcolor:black;pos:30,-40;','length:1;direction:down;fcolor:black;pos:20,20;',#叶子'length:2;direction:right;fcolor:black;pos:30,30;','length:1;direction:down;fcolor:black;pos:50,40;',
]#书本
notebook=['length:12;direction:right;fcolor:black;pos:0,0;symmetrical:21;symmetrical_direction:down','length:1;direction:right;fcolor:black;pos:120,-10;symmetrical:21;symmetrical_direction:down',#凹'length:13;direction:right;fcolor:black;pos:130,0;symmetrical:21;symmetrical_direction:down','length:21;direction:down;fcolor:black;pos:0,0;symmetrical:25;','length:5;direction:down;fcolor:black;pos:120,-10;',#中间
]
#字母
letter_p=['length:21;direction:down;fcolor:black;pos:0,0;','length:6;direction:right;fcolor:black;pos:0,0;symmetrical:8;symmetrical_direction:down','length:1;direction:right;fcolor:black;pos:60,-10;symmetrical:6;symmetrical_direction:down','length:5;direction:down;fcolor:black;pos:70,-20;',
]
letter_h=['length:21;direction:down;fcolor:black;pos:0,0;symmetrical:13;symmetrical_direction:right','length:13;direction:right;fcolor:black;pos:0,-80;',
]
letter_t=['length:13;direction:right;fcolor:black;pos:0,0;','length:18;direction:down;fcolor:black;pos:60,0;',
]
letter_m=['length:20;direction:right;fcolor:black;pos:0,0;','length:21;direction:down;fcolor:black;pos:0,0;symmetrical:20;symmetrical_direction:right','length:21;direction:down;fcolor:black;pos:100,0;',
]
letter_l=['length:21;direction:down;fcolor:black;pos:0,0;','length:14;direction:right;fcolor:black;pos:0,-210;',
]
letter_s=['length:10;direction:right;fcolor:black;pos:0,0;','length:10;direction:down;fcolor:black;pos:0,0;','length:10;direction:right;fcolor:black;pos:0,-100;symmetrical:9;symmetrical_direction:down','length:10;direction:down;fcolor:black;pos:100,-100;',
]letter_q=['length:10;direction:right;fcolor:black;pos:0,0;symmetrical:20;symmetrical_direction:down','length:20;direction:down;fcolor:black;pos:0,0;symmetrical:10;symmetrical_direction:right','length:5;direction:right;fcolor:black;pos:80,-150;',]
letter_j=['length:7;direction:right;fcolor:black;pos:0,0;','length:18;direction:down;fcolor:black;pos:70,0;','length:1;direction:down;fcolor:black;pos:60,-180;','length:1;direction:down;fcolor:black;pos:50,-190;','length:3;direction:left;fcolor:black;pos:40,-200;','length:1;direction:left;fcolor:black;pos:10,-190;','length:2;direction:up;fcolor:black;pos:0,-180;',
]#笑脸
happy_face=['length:26;direction:right;fcolor:black;pos:0,0;symmetrical:21;symmetrical_direction:down','length:21;direction:down;fcolor:black;pos:0,0;symmetrical:25;','length:7;direction:right;fcolor:black;pos:20,-85;symmetrical:14;','length:9;direction:right;fcolor:black;pos:80,-175;',#笑脸嘴'length:1;direction:right;fcolor:black;pos:70,-165;symmetrical:10;symmetrical_direction:right','length:1;direction:right;fcolor:black;pos:60,-155;symmetrical:12;symmetrical_direction:right',
]#dog face
dog_face=[#耳朵'length:9;direction:down;fcolor:black;pos:0,0;symmetrical:20;','length:2;direction:right;fcolor:black;pos:10,10;symmetrical:17;','length:1;direction:right;fcolor:black;pos:30,0;symmetrical:14;','length:1;direction:right;fcolor:black;pos:40,-10;symmetrical:12;','length:11;direction:right;fcolor:black;pos:50,-20;','length:1;direction:right;fcolor:black;pos:40,-30;symmetrical:12;','length:2;direction:down;fcolor:black;pos:30,-40;symmetrical:14;','length:2;direction:right;fcolor:black;pos:10,-60;symmetrical:17;',#脸蛋'length:7;direction:down;fcolor:black;pos:-10,-90;symmetrical:22;','length:2;direction:down;fcolor:black;pos:0,-160;symmetrical:20;','length:2;direction:right;fcolor:black;pos:10,-180;symmetrical:17;','length:2;direction:down;fcolor:black;pos:30,-190;symmetrical:14;','length:1;direction:down;fcolor:black;pos:40,-210;','length:2;direction:right;fcolor:black;pos:150,-210;','length:10;direction:right;fcolor:black;pos:50,-220;',#眼眶'length:2;direction:down;fcolor:black;pos:0,-110;symmetrical:12;','length:6;direction:right;fcolor:black;pos:10,-100;symmetrical:12;','length:2;direction:down;fcolor:black;pos:70,-110;symmetrical:12;','length:6;direction:right;fcolor:black;pos:10,-130;symmetrical:12;',#眼珠'length:2;direction:down;fcolor:black;pos:60,-110;symmetrical:12;','length:1;direction:down;fcolor:gray;pos:50,-110;symmetrical:12;','length:1;direction:down;fcolor:black;pos:50,-120;symmetrical:12;',#鼻子嘴巴'length:2;direction:down;fcolor:black;pos:70,-150;symmetrical:2;','length:5;direction:down;fcolor:black;pos:80,-150;','length:7;direction:right;fcolor:black;pos:60,-200;','length:1;direction:right;fcolor:black;pos:130,-190;','length:1;direction:right;fcolor:black;pos:140,-180;',
]#programer
programer=[#头发'length:3;direction:right;fcolor:black;pos:0,0;','length:11;direction:right;fcolor:black;pos:30,10;','length:2;direction:right;fcolor:black;pos:140,0;','length:1;direction:right;fcolor:black;pos:160,-10;','length:3;direction:right;fcolor:black;pos:170,-20;','length:4;direction:down;fcolor:black;pos:200,-30;','length:2;direction:left;fcolor:black;pos:190,-70;','length:2;direction:left;fcolor:black;pos:170,-80;','length:5;direction:up;fcolor:black;pos:150,-70;','length:2;direction:up;fcolor:black;pos:140,-70;','length:3;direction:left;fcolor:black;pos:140,-70;','length:3;direction:left;fcolor:black;pos:110,-80;','length:1;direction:left;fcolor:black;pos:80,-70;','length:2;direction:left;fcolor:black;pos:70,-80;','length:1;direction:left;fcolor:black;pos:50,-70;','length:3;direction:down;fcolor:black;pos:40,-60;','length:4;direction:left;fcolor:black;pos:30,-80;','length:5;direction:down;fcolor:black;pos:-10,-80;',#左侧脸最左侧坐标'length:2;direction:up;fcolor:black;pos:-20,-110;','length:8;direction:up;fcolor:black;pos:-30,-100;','length:1;direction:up;fcolor:black;pos:-20,-20;','length:1;direction:up;fcolor:black;pos:-10,-10;',#脸廓'length:2;direction:down;fcolor:black;pos:0,-130;','length:6;direction:down;fcolor:black;pos:10,-150;','length:1;direction:down;fcolor:black;pos:20,-210;','length:12;direction:right;fcolor:black;pos:30,-220;','length:1;direction:right;fcolor:black;pos:150,-210;','length:1;direction:right;fcolor:black;pos:160,-200;','length:11;direction:up;fcolor:black;pos:170,-190;',#眼睛'length:4;direction:right;fcolor:black;pos:40,-105;symmetrical:8;',#眉毛'length:2;direction:down;fcolor:black;pos:70,-125;symmetrical:5;',#嘴巴'length:2;direction:down;fcolor:black;pos:50,-175;symmetrical:8;','length:2;direction:down;fcolor:black;pos:50,-175;symmetrical:8;','length:7;direction:right;fcolor:black;pos:60,-195;',
]#赞
zan=[#袖子'length:6;direction:down;fcolor:black;pos:0,0;symmetrical:3;',    'length:4;direction:right;fcolor:black;pos:0,10;symmetrical:7;symmetrical_direction:down;', #拇指'length:1;direction:down;fcolor:black;pos:40,10;','length:1;direction:down;fcolor:black;pos:50,20;symmetrical:4;','length:1;direction:down;fcolor:black;pos:60,30;','length:3;direction:up;fcolor:black;pos:70,40;','length:1;direction:up;fcolor:black;pos:80,70;symmetrical:2;','length:2;direction:right;fcolor:black;pos:90,80;','length:6;direction:down;fcolor:black;pos:100,80;',#握拳'length:6;direction:right;fcolor:black;pos:80,10;','length:6;direction:down;fcolor:black;pos:140,10;','length:1;direction:down;fcolor:black;pos:130,-50;','length:9;direction:left;fcolor:black;pos:120,-60;',
]

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/287456.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【小程序】刘一哥课堂随机点名提问神器V1.0(附源程序)

为了能让我们的孩子们尽量来教室上课,增强课堂的参与度,激发课堂激情,提高学习效率,一哥也是煞费苦心,于是开发出了这么一款课堂点名提问神器,跟大家分享一下。 打开神器,看到的界面是这样子的,我很感激有勇气按时起床并能到教室的每一位有志之士。 点击【开始】按钮,…

Git客户端TortoiseGit(Windows系统)的使用方法

本文环境: 操作系统:Windows XP SP3 Git客户端:TortoiseGit-1.8.8.0-32bit 一、安装Git客户端 全部安装均采用默认! 1. 安装支撑软件 msysgit: https://code.google.com/p/msysgit/downloads/list?qfullinstallerofficialgit 当前…

.Net 在容器中操作宿主机

1方案描述 在 docker 容器中想操作宿主机,一般会使用 ssh 的方式,然后 .Net 通过执行远程 ssh 指令来操作宿主机。本文将使用 交互式 .Net 容器版 中提供的镜像演示 .Net 在容器中如何操作宿主机。2前期准备 1. 宿主机上生成 ssh key生成 ss…

【看动漫学编程】程序员在异世界生个娃 第1篇:太极村

前言 作者文笔比较水,还请见谅。 以下内容还将使用视频动态漫画表现,剪辑完将会贴出链接。 小说剧情为剧情需要,过渡到知识点,部分篇幅可能没有技术知识点还望谅解。 由于没有经费支持,所以画出来的东西是我自己用代码…

【ArcGIS风暴】最牛逼空间数据批处理神器来了:用户自定义工具箱GeoStorm.tbx

【Warming up】在学习和工作的过程中,作者曾写过很多采用ArcGIS模型构建器(Model Builder)、Python代码等批处理方法(感兴趣的GISers可以去【测绘地理信息Big风暴专】栏去交流学习指导),大大的减轻了操作压力,提高了工作效率。今天给大家展示一款神器:自定义工具箱GeoS…

Linux下c/c++项目代码覆盖率的产生方法

最近做了一系列的单元测试相关的工作,除了各种规范及测试框架以外,讨论比较多的就是关于代码覆盖率的产生,c/c与其他的一些高级语言或者脚本语言相比较而言,例如 Java、.Net和php/python/perl/shell等,由于没有这些高级…

C# WPF从后台代码生成行列可变的表格

z概述WPF常用的表格控件是DataGrid,这个控件在前台XAML编写的话,一般列已经固定,然后给每个列去绑定数据,但是如果我的列不固定,随着运算结果变动呢?这时候DataGrid,就比较难实现这个需求&#…

软件架构实践文章链接

2019独角兽企业重金招聘Python工程师标准>>> 架构 InfoQ: 又拍网架构中的分库设计 SNS网站数据库技术分析 - 51CTO.COM 数据库水平切分的实现原理解析 - iBATIS - Java - JavaEye论坛 基于amoeba的mysql分布式数据库学习(一) - Java - JavaEy…

数据库SQL语句学习笔记(6)-使用函数处理数据

1.SQL也可以用函数来处理数据,函数一般是在数据上执行的,为数据的转换和处理提供了方便。但是每一个数据库管理系统(DBMS)都有特定的函数,事实上,只有少数几个函数被所有的DBMS等同地支持。例如&#xff0c…

【遥感物候】Matlab求解一元六次多项式,计算植被生长季始期

一元六次多项式能很好的逼近滤波后的曲线,与二次多项式相比,在拟合植被整个生长季曲线方面有更好的优势,该方法常用来描述北方温带和高纬度地区时序NDVI生长季模式。因此,本文使用一元六次多项式来拟合植被整个生长季曲线,效果很好。那么拟合后,这样解方程呢求生长季参数…

最全面透彻的RabbitMQ指南

概念RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件)。RabbitMQ服务器是用Erlang语言编写的,而集群和故障转移是构建在开放电信平台框架上的。所有主要的编程语言均有与代理接口通讯…

TensorFlow中RNN实现的正确打开方式

上周写的文章《完全图解RNN、RNN变体、Seq2Seq、Attention机制》介绍了一下RNN的几种结构,今天就来聊一聊如何在TensorFlow中实现这些结构,这篇文章的主要内容为: 一个完整的、循序渐进的学习TensorFlow中RNN实现的方法。这个学习路径的曲线较…

《看聊天记录都学不会C语言?太菜了吧》(2)我说编程很容易你们不服?

若是大一学子或者是真心想学习刚入门的小伙伴可以私聊我,若你是真心学习可以送你书籍,指导你学习,给予你目标方向的学习路线,无套路,博客为证。 本系列文章将会以通俗易懂的对话方式进行教学,对话中将涵盖…

LCD1602,4位数据总线液晶屏时钟,STC12C5A60S2的10位ADC功能程序

/* 程序名:    LCD1602,4位数据总线液晶屏时钟,STC12C5A60S2的10位ADC功能程序 编写时间:  2015年10月4日 硬件支持:  LCD1602液晶屏 STC12C5A60S2 外部12MHZ晶振 接线定义: DB7 --> P1^7DB6…

WPF|黑暗模式的钱包支付仪表盘界面设计

收集下大家的意见,是否需要在文中贴上源码(文末会给出源码链接),请大家踊跃留言。阅读目录效果展示准备简单说明 源码结尾(视频及源码仓库)1. 效果展示欣赏效果:2. 准备创建一个WPF工程&#x…

《看聊天记录都学不会C语言?太菜了吧》(3)人艰不拆,代码都在谈恋爱?!

若是大一学子或者是真心想学习刚入门的小伙伴可以私聊我,若你是真心学习可以送你书籍,指导你学习,给予你目标方向的学习路线,无套路,博客为证。 本系列文章将会以通俗易懂的对话方式进行教学,对话中将涵盖…

DB2常用命令

查看DB2License信息 DB2基础命令 转载于:https://www.cnblogs.com/arcer/p/5573317.html

.NET7 Preview4之MapGroup

这篇是“闻(看)香(码)识(学)女(技)人(术)”。这也是一个有意思的功能,路由分组,啥也不说了,看代码看结果:using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.OpenApi;var builder WebApplication.Create…

【空间数据库】ArcGIS 10.6 Database_Server_Desktop安装、连接数据库服务、创建企业级数据库(附server10.6.ecp)

由于作者一直使用SQL Server 2008 R2开发版,之前在ArcGIS中创建企业级数据库都是基于单独安装的SQL Server 2008 R2开发版,今天我们演示安装ArcGIS10.6自带的数据库服务(SQL Server 2014 Express版本)、连接数据库服务和创建数据库。 首先,我们来看一下完整的ArcGIS10.6安…

(一)easyUI之树形网络

树形网格&#xff08;TreeGrid&#xff09;可以展示有限空间上带有多列和复杂数据电子表 一、案例一&#xff1a;按tree的数据结构来生成 前台<% page language"java" contentType"text/html; charsetUTF-8"pageEncoding"UTF-8"%> <!DO…