[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
作为一个世界上非著名非专业的画家,当然得让大家先欣赏下我的世纪大作:
当然作为一个知名画家必须得掌握不同的画风,现在大家欣赏下我的另一大作:
众所周知,作为一个程序员,当然不会是一个手残党,日夜敲击键盘和晚上去厕所锻炼出来的手速,画这么个樱花树不是分分钟?这棵樱花树,我们使用了python的turtle模块,利用一些数学函数,将随机的画出不同的树枝以及飘落的花瓣,我们每次运行都会生成一棵相对独一无二的树(假如随机数不会相同)。废话不多说,看源码吧:
import turtle
from random import *
from math import *
def tree(n, l):
turtle.pendown()
t = cos(radians(turtle.heading() + 45)) / 8 + 0.25
turtle.pencolor(t, t, t)
turtle.pensize(n / 3)
turtle.forward(l)
if n > 0:
b = random() * 15 + 10
c = random() * 15 + 10
d= l * (random() * 0.25 + 0.7)
turtle.right(b)
tree(n - 1, d)
turtle.left(b + c)
tree(n - 1, d)
turtle.right(c)
else:
turtle.right(90)
n = cos(radians(turtle.heading() - 45)) / 4 + 0.5
turtle.pencolor(n, n*0.8, n*0.8)
turtle.circle(3)
turtle.left(90)
z=random()
if z>0.7:
turtle.up()
t = turtle.heading()
an = -40 + random()*40
turtle.setheading(an)
dis = int(800*random()*0.5 + 400*random()*0.3 + 200*random()*0.2)
turtle.forward(dis)
turtle.setheading(t)
turtle.down()
turtle.right(90)
n = cos(radians(turtle.heading() - 45)) / 4 + 0.5
turtle.pencolor(n*0.5+0.5, 0.4+n*0.4, 0.4+n*0.4)
turtle.circle(2)
turtle.left(90)
turtle.up()
t = turtle.heading()
turtle.setheading(an)
turtle.backward(dis)
turtle.setheading(t)
turtle.up()
turtle.backward(l)
turtle.bgcolor(0.5, 0.5, 0.5) # 背景色
turtle.hideturtle() # 隐藏turtle
turtle.speed(0) # 速度,1-10渐进,0最快
turtle.tracer(0, 0)
turtle.up() # 抬笔
turtle.backward(100)
turtle.left(90) # 左转90度
turtle.up() # 抬笔
turtle.backward(300) # 后退300
tree(12, 100) # 递归7层
turtle.done()