目录
代码效果
题目要求
具体内容可参阅课程教学网站或超星学习通。
按照2人一组,结对编程;
使用 Python Turtle 库创意绘图,主题内容均不限,但不违背“公序良俗”。
合作同学
学号:20181101051,韩旭
学号:20160515055,孔惠琴
程序实现
最初目标
实现方式
- 本着思维上的懒惰,行为上的努力
-所以没用函数等新学的工具去写
而是站在初学者的角度,只学会了使用goto这一个语句来进行绘画绘画
把turtle库玩成了十字绣
通过Windows系统自带的画图工具去找点,随便写一个Excel表格,根据一些特别简单的函数,转换成turtle里面的坐标并变成goto代码的形式
其实明明可以用python做,但是为了使用多种软件联动,就随便写了
- 写的很用心,也可以说写的不用心。
- 用的都是最简单的,这些代码,让没有python基础的,简单学习就能上手。
- 实现的代码,不是最简洁的,不是最高效的,而是最省脑子的.
- 写起来感觉很舒服,啥也没有考虑,但是时间很长....
- 小组合作很重要,很重要吧....
- 五一放假前很忙,作业堆在一起了,所以也就一起写了..(???!!!越忙越不干正事)
代码如下
from turtle import *
import random
def heart(x,y):
up()
goto(x,y)
down()
z=random.randint(10,50)
write("♥", font=("Times", z, "bold"))
up()
screensize(800,650, "lightblue")#新建画布
pencolor('pink')
fillcolor('pink')
begin_fill()
left(90)
circle(30,180)
circle(90,70)
left(38)
circle(90,70)
circle(30,180)
end_fill()
up()
penup()
pensize(3)
pencolor('white')
#画人物轮廓部分
goto(-130, -139)
pendown()
clear()
goto(-130,-139)
goto(-127,-112)
goto(-118,-88)
goto(-133,-80)
goto(-148,-59)
goto(-153,-35)
goto(-156,-12)
goto(-152,6)
goto(-144,20)
goto(-140,23)
goto(-125,33)
goto(-109,44)
goto(-85,49)
goto(-66,51)
goto(-18,35)
goto(4,14)
goto(-24,40)
goto(-11,24)
goto(11,-4)
goto(12,-42)
goto(1,-67)
goto(-32,-83)
goto(-14,-80)
goto(9,-78)
goto(12,-80)
goto(14,-75)
goto(23,-91)
goto(12,-105)
goto(-10,-103)
goto(-27,-112)
goto(-26,-131)
goto(-30,-137)
penup()
#画面部表情部分
pencolor('black')
goto(-75,-35)
pendown()
goto(-49,-33)
goto(-48,-45)
goto(-59,-52)
goto(-69,-49)
goto(-77,-32)
goto(-75,-35)
penup()
goto(-108,-4)
pendown()
circle(10)
penup()
goto(-43,-5)
pendown()
circle(10)
#画心形部分
pensize(1)
pencolor('white')
fillcolor('white')
speed(5)
up()
goto(70, -123)
#位置-30,100换100-17
#差-130-117
down()
pencolor('red')
write("♥", font = ("Times", 107,"bold"))
up()
#位置-230-217 -100,-100
#写字部分
pencolor('red')
goto(-170, 170)
down()
write("超级", font = ("Times", 48,"bold"))
up()
circle(50,360)
down()
undo()
undo()
goto(-40, 170)
write("爱你", font = ("Times", 48,"bold"))
penup()
circle(50,10)
goto(-135,-58)
write("???", font = ("Times", 58,"bold"))
goto(-200, 130)
write("爱你到忘记自我", font = ("Times", 28,"bold"))
goto(-200, 190)
color('white')
screensize(800,600, "black")#新建画布
pendown()
goto(-90, 100)
write("爱你到黑白颠倒", font = ("Times", 28,"bold"))
screensize(800,600, "black")#新建画布
penup()
circle(50,25)
goto(-200, 50)
pendown()
color('black')
write("爱你到黑白颠倒", font = ("Times", 38,"bold"))
penup()
circle(50,25)
screensize(800,600, "white")#新建画布
circle(50,25)
screensize(800,600, "black")#新建画布
circle(50,5)
screensize(800,600, "blue")#新建画布
screensize(800,600, "white")#新建画布
circle(50,25)
screensize(800,600, "black")#新建画布
circle(50,5)
screensize(800,600, "white")#新建画布
screensize(800,600, "white")#新建画布
circle(50,25)
screensize(800,600, "black")#新建画布
circle(50,5)
screensize(800,600, "white")#新建画布
screensize(800,600, "white")#新建画布
circle(50,25)
screensize(800,600, "black")#新建画布
circle(50,5)
screensize(800,600, "white")#新建画布
screensize(800,600, "white")#新建画布
circle(50,25)
screensize(800,600, "black")#新建画布
circle(50,5)
screensize(800,600, "white")#新建画布
screensize(800,600, "white")#新建画布
circle(50,25)
screensize(800,600, "black")#新建画布
circle(50,5)
pendown()
screensize(800,600, "white")#新建画布
undo()
undo()
penup()
circle(50,25)
pendown()
screensize(800,600, "black")#新建画布
screensize(800,600, "pink")#新建画布
color('white')
goto(-130, -139)
write("爱你到天昏地暗", font = ("Times", 38,"bold"))
for i in range(25):
if i%2==0:
pencolor('white')
else :
pencolor('red')
m=random.randint(-200,200)
n=random.randint(-200,200)
heart(m,n)
circle(50,25)
来源:oschina
链接:https://my.oschina.net/u/4324171/blog/3556290