浪漫表白代码

吃下这波狗粮,您就是全栈!

生活有望穿秋水的等待,也会有意想不到的惊喜,世间美好与你环环相扣,有你在的地方那就是尽头! 人生最大的’‘错误’’ 或许就是,嫁给了比谁都浪漫的程序员!

爱心穿云箭

会挽雕弓如满月,西北望射天狼。

from turtle import *

def go_to(x, y):
    up()
    goto(x, y)
    down()
    
def small_Circle(size):  # 函数用于绘制心的小圆
    speed(10)
    for i in range(210):
        forward(size)
        right(0.786)
        
def big_Circle(size):  # 函数用于绘制心的大圆
    speed(10)
    for i in range(150):
        forward(size)
        right(0.3)
        
def line(size):
    speed(10)
    forward(51 * size)
    
def heart(x, y, size):
    go_to(x, y)
    left(150)
    begin_fill()
    line(size)
    big_Circle(size)
    small_Circle(size)
    left(120)
    small_Circle(size)
    big_Circle(size)
    line(size)
    end_fill()
    
def arrow():
    pensize(10)
    setheading(0)
    go_to(-320,0)
    left(15)
    forward(250)
    go_to(170, 130)
    left(2)
    forward(100)

def arrowHead():
    pensize(1)
    speed(1)
    color('red', 'red')
    begin_fill()
    left(120)
    forward(20)
    right(150)
    forward(35)
    right(120)
    forward(35)
    right(150)
    forward(20)
    end_fill()

def main():
    pensize(2)
    color('red', 'pink')
    getscreen().tracer(1, 0)
    heart(100, 0, 0.7)
    go_to(80, 70)
    write("宝贝", font=("楷体", 25, "normal"))
    setheading(0)
    heart(-80, -100, 1)
    go_to(-110, 15)
    write("真巧", font=("宋体", 20, "normal"))
    arrow()  # 画出穿过两颗心的直线
    arrowHead()  # 画出箭的箭头
    go_to(40, -80)
    write("刚好遇见你!", move=True, align="left", font=("arial", 22, "italic"))
    done()
main()

在这里插入图片描述

风雨彩虹,铿锵玫瑰

爱意东升日落,浪漫至死不渝。

from turtle import *
speed(5)  # 画笔移动的速度
# 设置初始位置

penup()  # 提起画笔,移动画笔但并不会绘制图形

left(90)  # 逆时针转动画笔90度

fd(200)

pendown()  # 放下画笔,移动画笔即开始绘制

right(90)

# 设置画笔的大小
pensize(2)

# 花蕊

fillcolor("red")  # 填充颜色

begin_fill()  # 开始填充

circle(10, 180)

circle(25, 110)

left(50)

circle(60, 45)

circle(20, 170)

right(24)

fd(30)

left(10)

circle(30, 110)

fd(20)

left(40)

circle(90, 70)

circle(30, 150)

right(30)

fd(15)

circle(80, 90)

left(15)

fd(45)

right(165)

fd(20)

left(155)

circle(150, 80)

left(50)

circle(150, 90)

end_fill()  # 结束填充

# 花瓣1

left(150)

circle(-90, 70)

left(20)

circle(75, 105)

setheading(60)

circle(80, 98)

circle(-90, 40)

# 花瓣2

left(180)

circle(90, 40)

circle(-80, 98)

setheading(-83)

# 叶子1

fd(30)

left(90)

fd(25)

left(45)

fillcolor("green")

begin_fill()

circle(-80, 90)

right(90)

circle(-80, 90)

end_fill()

right(135)

fd(60)

left(180)

fd(85)

left(90)

fd(80)

# 叶子2

right(90)

right(45)

fillcolor("green")

begin_fill()

circle(80, 90)

left(90)

circle(80, 90)

end_fill()

left(135)

fd(60)

left(180)

fd(60)

right(90)

circle(200, 50)  # 画一个圆 200 是半径,50 是弧度

write("风雨彩虹,铿锵玫瑰 !", font=('Arial', 17, 'bold italic'))
penup()
goto(100,200)
pendown()
write("爱意东升日落,浪漫至死不渝!", font=('Arial', 15, 'bold italic' ))

# 不让自动退出,放在程序的最后一行
# 不然画画结束后会自动退出
done()

在这里插入图片描述

一行代码,N层爱意

码有尽,而意无穷 !

print('\n'.join([''.join([('I Love You'[(x-y)%8]if((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3<=0 else' ')for x in range(-40,40)])for y in range(20,-20,-1)]))

在这里插入图片描述

送你一朵小红花

最台词:你呀,得出干点你这个年龄该干的事情,多出去看看,多走走 !

from turtle import *
def main():
    pensize(5)#设置画笔大小
    left(60)#向左旋转60度
    speed(-20)#设置画笔速度
    color("#FFC125")#画笔颜色
    InCircle() #调用画内圈函数
    OutCircle() #调用画外圈函数
    right(162)
    forward(500)
    penup()
    goto(40, 160)
    pendown()
    write("送你一朵小红花 !", move=True, align="left", font=("arial", 22, "italic"))
    #绘制结束,显示绘图结果,黑窗口不会自动关闭,等待用户X掉
    done()

def InCircle():
    fillcolor('red')  # 填充颜色
    begin_fill()  # 颜色填充起点
    for i in range(5):
        circle(50,288)#半径为50,弧度288
        penup()#抬笔
        circle(50,72)#72度弧隐藏
        pendown()#落笔
        left(72)
    end_fill()#颜色填充终点
def OutCircle():
    for i in range(5):
        circle(80,288)
        penup()
        circle(80,72)
        pendown()
        left(72)
main()

在这里插入图片描述

太阳金光闪闪

多姿多彩,欣欣向荣;心有猛虎,细嗅蔷薇 !

from turtle import *
color("red","yellow")
#涉及到填充,要调用begin_fill()函数
begin_fill()
for i in range(36):
    fd(250)
    left(170) #首次以水平向右直线为参照物,向左旋转170度,依次类推,直到画完36次为止
end_fill()
penup()
goto(0,150)
pendown()
write("太阳金光闪闪 !", move=True, align="left", font=("arial", 22, "italic"))
done()

在这里插入图片描述

星点漩涡图

我会住在其中一颗星星上面,在某一颗星星上微笑着,每当夜晚你望星空的时候,就会像是看到所有的星星都在微笑,众里寻星千百度,蓦然回首,那星却在,灯火阑珊处

import random
from turtle import *
colors = ['red','blue','pink','yellow','green','orange']
speed(-1)
bgcolor('black')
length=100
angle=50
size=5
for i in range(length):
    color=random.choice(colors)
    pencolor(color)
    fillcolor(color)
    penup()
    forward(i+50)
    pendown()
    left(angle)
    begin_fill()
    circle(size)
    end_fill()
done()

在这里插入图片描述
好啦,为了做一名全栈程序员,感谢您和up一起吃下这波狗粮啦,为了咱们共同的梦想,一起加油鸭, !

  • 29
    点赞
  • 44
    收藏
    觉得还不错? 一键收藏
  • 27
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 27
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值