栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

程序员的520,送给女友的几行漂亮的代码(python版)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

程序员的520,送给女友的几行漂亮的代码(python版)

效果1:

import turtle
 
import time
 
t = turtle.Turtle()
t.speed(1)
 
# 设置初始位置
t.penup()
t.left(90)
t.fd(200)
t.pendown()
t.right(90)
 
# 花蕊
t.fillcolor("red")
t.begin_fill()
t.circle(10, 180)
t.circle(25, 110)
t.left(50)
t.circle(60, 45)
t.circle(20, 170)
t.right(24)
t.fd(30)
t.left(10)
t.circle(30, 110)
t.fd(20)
t.left(40)
t.circle(90, 70)
t.circle(30, 150)
t.right(30)
t.fd(15)
t.circle(80, 90)
t.left(15)
t.fd(45)
t.right(165)
t.fd(20)
t.left(155)
t.circle(150, 80)
t.left(50)
t.circle(150, 90)
t.end_fill()
 
# 花瓣1
t.left(150)
t.circle(-90, 70)
t.left(20)
t.circle(75, 105)
t.setheading(60)
t.circle(80, 98)
t.circle(-90, 40)
 
# 花瓣2
t.left(180)
t.circle(90, 40)
t.circle(-80, 98)
t.setheading(-83)
 
# 叶子1
t.fd(30)
t.left(90)
t.fd(25)
t.left(45)
t.fillcolor("green")
t.begin_fill()
t.circle(-80, 90)
t.right(90)
t.circle(-80, 90)
t.end_fill()
t.right(135)
t.fd(60)
t.left(180)
t.fd(85)
t.left(90)
t.fd(80)
 
# 叶子2
t.right(90)
t.right(45)
t.fillcolor("green")
t.begin_fill()
t.circle(80, 90)
t.left(90)
t.circle(80, 90)
t.end_fill()
t.left(135)
t.fd(60)
t.left(180)
t.fd(60)
t.right(90)
t.circle(200, 60)
time.sleep(5)

 

效果2

代码:

from turtle import *
from colorsys import *
 
 
def curve():
	for i in range(200):
		right(1)
		forward(1)
 
tracer(10)
delay(0)
speed(0)
pensize(3)
bgcolor("black")
 
left(140)
 
cycles_number=2
for _ in range(cycles_number):
	s=1
	for i in range(36):
		color("#C90055",hsv_to_rgb(0.92,s,1))
		begin_fill()
		forward(111.65)
		curve()
		left(120)
		curve()
		forward(111.65)
		end_fill()
		hideturtle()
		right(90)
		s-=0.02
done()

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/892485.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号