惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
博客园 - Franky
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
博客园 - 司徒正美
N
News and Events Feed by Topic
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
Help Net Security
Help Net Security
N
News and Events Feed by Topic
O
OpenAI News
L
LangChain Blog
F
Full Disclosure
A
About on SuperTechFans
The GitHub Blog
The GitHub Blog
GbyAI
GbyAI
Cloudbric
Cloudbric
W
WeLiveSecurity
Application and Cybersecurity Blog
Application and Cybersecurity Blog
罗磊的独立博客
Attack and Defense Labs
Attack and Defense Labs
PCI Perspectives
PCI Perspectives
TaoSecurity Blog
TaoSecurity Blog
AI
AI
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
T
The Exploit Database - CXSecurity.com
T
Threatpost
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Last Week in AI
Last Week in AI
雷峰网
雷峰网
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园 - 聂微东
P
Proofpoint News Feed
Latest news
Latest news
S
SegmentFault 最新的问题
J
Java Code Geeks
T
Threat Research - Cisco Blogs
H
Help Net Security
P
Privacy International News Feed

博客园 - ®Geovin Du Dream Park™

go: Functional Options Pattern go:Timing Functions Pattern python: Timing Functions Pattern go: Steady-State Pattern python: Steady-State Pattern go: Handshaking Pattern python: Handshaking Pattern go: Fail-Fast Pattern python: Fail-Fast Pattern I go: Deadline Pattern python: Deadline Pattern go: Circuit-Breaker Pattern python: Circuit-Breaker Pattern go: Bulkheads Pattern python: Bulkheads Pattern go: Push & Pull Pattern python: Push & Pull Pattern python: Publish/Subscribe Pattern II go: Publish/Subscribe Pattern python: Publish/Subscribe Pattern go: Futures & Promises Pattern python: Futures & Promises Pattern go: Worker Pool Pattern go:Pipeline Pattern python: Worker Pool Pattern python: Pipeline Pattern go: Fan-Out Pattern python: Fan-Out Pattern go: Fan-In Pattern python: Fan-In Pattern Fan-In go: Producer Consumer  Pattern python: Producer Consumer Pattern go: Parallelism Pattern python: Parallelism Pattern go: Reactor Pattern python: Reactor Pattern go: Generators Pattern python: speech to text offline python: Generators Pattern go: Coroutines Pattern python:Coroutines Pattern go: Broadcast Pattern python: Broadcast Pattern python: Bounded Parallelism Pattern go: Bounded Parallelism Pattern python: N-Barrier Pattern go: N-Barrier Pattern python: Semaphore Pattern go: Semaphore Pattern python: Read-Write Lock Pattern go: Read-Write Lock Pattern python: Monitor Pattern go: Monitor Pattern python: Mutex Pattern go: Lock/Mutex Pattern Python: Condition Variable Pattern go:Condition Variable Pattern python: Registry Pattern python: Interpreter Pattern go: Interpreter Pattern go: Registry Pattern go: Memento Pattern go: Command Pattern go: State Pattern go:Template Method Pattern go: Strategy Pattern go: Visitor Pattern go: Observer Pattern go: Mediator Pattern go: Iterator Pattern go: Chain of Responsibility Pattern go: Proxy Pattern go:Decorator Pattern go: Facade Pattern go: Flyweight Pattern go: Composite Pattern go: Singleton Pattern go: Prototype Pattern go: Bridge Pattern go: Adapter Pattern go: Builder Pattern 密码进行加盐哈希 using CSharp,Python,Go,Java go: Abstract Factory Pattern go: Model,Interface,DAL ,Factory,BLL using mysql go: Simple Factory Pattern go: Factory Method Pattern go: goLang 在Windows环境搭建Go语言开发环境 CSharp: Parallel Extensions cpp: class javascript: 中国历史人物热力分布图using echart javascript: 中国历史人物热力图 python: 初养龙虾微信纯文字自动回复using workBuddy python: object 入门 python: Factory Method Pattern python: Simple Factory Pattern python: Abstract Factory Pattern 区域化 代码 python: Null Object Pattern python: Builder Pattern python: Adapter Pattern
python: 蝴蝶跟随鼠标
®Geovin Du Dream Park™ · 2026-03-28 · via 博客园 - ®Geovin Du Dream Park™
# encoding: utf-8 
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2024.3.6 python 3.11
# os        : windows 10
# database  : mysql 9.0 sql server 2019, postgreSQL 17.0  Oracle 21c Neo4j
# Datetime  : 2026/3/28 14:00 
# User      :  geovindu
# Product   : PyCharm
# Project   : Pysimple
# File      : buttyerfly4.py
import turtle as tur
import random
import math


# 颜色
color1 = "#f6aa0c"
color2 = "#0099ff"
color3 = "#f83079"
color4 = "#72e7fb"

# ===================== 飞行参数 =====================
tx, ty = 0, 0
bx, by = 0, 0
frame = 0
stars = []



# ===================== 你原版完整蝴蝶(100% 对称) =====================
def go_to(pos:float):
    """

    :param pos:
    :return:
    """
    tur.up()
    tur.goto(pos[0], pos[1])
    tur.down()

def rel_pos(x:float,y:float):
    """

    :param x:
    :param y:
    :return:
    """
    tur.up()
    tur.goto(tur.pos()+(x,y))
    tur.down()

def draw_oval(width:float, height:float, color:str):
    """

    :param width:
    :param height:
    :param color:
    :return:
    """
    tur.fillcolor(color)
    tur.begin_fill()
    for _ in range(2):
        tur.circle(height/2, 45)
        tur.circle(width/2, 135)
    tur.end_fill()

def draw_heart(size:float):
    """

    :param size:
    :return:
    """
    tur.left(50)
    tur.forward(size)
    tur.circle(size * 0.5, 200)
    tur.right(140)
    tur.circle(size * 0.5, 200)
    tur.forward(size+5)
    tur.left(50)

def rightwings(top_pos:float, flap:float):
    """

    :param top_pos:
    :param flap:
    :return:
    """
    go_to(top_pos)
    tur.seth(-65 + flap)
    tur.circle(-200,35)
    cur_pos = tur.pos()
    tur.begin_fill()
    tur.fillcolor(color1)
    draw_heart(100)
    tur.end_fill()
    go_to((cur_pos[0],cur_pos[1] + 20))
    tur.begin_fill()
    tur.fillcolor(color2)
    draw_heart(80)
    tur.end_fill()
    rel_pos(60,-70)
    tur.seth(-45)
    draw_oval(20,50,color3)
    rel_pos(-25,30)
    draw_oval(10, 30, color3)
    rel_pos(-10, -15)
    draw_oval(10,20,color4)
    go_to(top_pos)
    tur.seth(-65 + flap)
    tur.circle(-200,20)
    cur_pos = tur.pos()
    tur.begin_fill()
    tur.fillcolor(color1)
    draw_heart(100)
    tur.end_fill()
    go_to(cur_pos)
    tur.begin_fill()
    tur.fillcolor(color2)
    draw_heart(80)
    tur.end_fill()
    rel_pos(50,30)
    tur.seth(10)
    draw_oval(10,60,color3)
    rel_pos(40,-5)
    draw_oval(20,60,color4)
    rel_pos(-10,-40)
    draw_oval(20,40,color3)
    tur.seth(-45)
    rel_pos(0,-45)
    draw_oval(10,80,color4)
    rel_pos(-30,20)
    draw_oval(10,30,color4)
    rel_pos(-30,30)
    draw_oval(25,30,color3)

def leftWings(top_pos:float, flap:float):
    """

    :param top_pos:
    :param flap:
    :return:
    """
    go_to(top_pos)
    tur.seth(-110 - flap)
    tur.circle(200,22)
    cur_pos = tur.pos()
    tur.seth(100)
    tur.begin_fill()
    tur.fillcolor(color1)
    draw_heart(100)
    tur.end_fill()
    go_to((cur_pos[0], cur_pos[1] + 10))
    tur.begin_fill()
    tur.fillcolor(color2)
    draw_heart(80)
    tur.end_fill()
    rel_pos(-80, -45)
    tur.seth(-135)
    draw_oval(20, 50, color3)
    rel_pos(25,30)
    draw_oval(10,30,color4)
    rel_pos(30,10)
    draw_oval(10,20,color3)
    go_to(top_pos)
    tur.seth(-110 - flap)
    tur.circle(200,5)
    cur_pos = tur.pos()
    tur.seth(90)
    tur.begin_fill()
    tur.fillcolor(color1)
    draw_heart(100)
    tur.end_fill()
    go_to((cur_pos[0], cur_pos[1] -15))
    tur.begin_fill()
    tur.fillcolor(color2)
    draw_heart(80)
    tur.end_fill()
    rel_pos(-90,50)
    tur.seth(110)
    draw_oval(10,60,color4)
    rel_pos(40,-5)
    draw_oval(20,60,color4)
    rel_pos(-10,-40)
    draw_oval(20,40,color3)
    tur.seth(-150)
    rel_pos(-29,-30)
    draw_oval(10,80,color4)
    rel_pos(-30,20)
    draw_oval(10,30, color3)
    rel_pos(90,15)
    draw_oval(10,30,color3)

def drawWings(top_pos:float, flap:float):
    """

    :param top_pos:
    :param flap:
    :return:
    """
    rightwings(top_pos, flap)
    leftWings(top_pos, flap)

def drawButterfly(x:float, y:float, flap:float):
    """

    :param x:
    :param y:
    :param flap:
    :return:
    """
    tur.penup()
    tur.goto(x, y)
    tur.pendown()
    tur.seth(70)
    tur.circle(200,45)
    top_pos = tur.pos()
    tur.seth(-110)
    tur.circle(200,45)
    go_to(top_pos)
    tur.seth(0)
    tur.begin_fill()
    tur.fillcolor(color2)
    tur.circle(10)
    tur.end_fill()
    tur.circle(10, 180)
    tur.width(3)
    cur_pos = tur.pos()
    tur.seth(90)
    tur.circle(50,60)
    go_to(cur_pos)
    tur.seth(90)
    tur.circle(-50,60)
    tur.width(2)
    drawWings(top_pos, flap)
    go_to((x, y))
    tur.begin_fill()
    tur.fillcolor(color1)
    tur.seth(70)
    tur.circle(200,45)
    top_pos = tur.pos()
    tur.seth(-110)
    tur.circle(200,45)
    tur.end_fill()
    tur.begin_fill()
    tur.fillcolor(color3)
    tur.seth(70)
    tur.circle(200,20)
    tur.seth(180)
    tur.forward(30)
    tur.seth(-85)
    tur.circle(200,20)
    tur.end_fill()
    tur.begin_fill()
    tur.fillcolor(color1)
    tur.seth(70)
    tur.circle(200,15)
    tur.seth(180)
    tur.forward(27)
    tur.seth(-81)
    tur.circle(200,15)
    tur.end_fill()
    go_to((x, y))
    tur.begin_fill()
    tur.fillcolor(color4)
    tur.seth(70)
    tur.circle(200, 10)
    tur.seth(180)
    tur.forward(20)
    tur.seth(-75)
    tur.circle(200,10)
    tur.end_fill()



# ===================== 鼠标点击跟随 =====================
def on_click(x:float, y:float):
    """

    :param x:
    :param y:
    :return:
    """
    global tx, ty
    tx, ty = x, y



# ===================== 动画:飞 + 扇动 + 闪烁 =====================
def animate():
    """

    :return:
    """
    global frame, bx, by
    frame += 1
    tur.clear()

    # 星光闪烁
    for s in stars:
        t, size, color, phase = s
        phase += 0.15
        s[3] = phase
        r = size * (0.5 + abs(math.sin(phase)))
        t.dot(max(1, r), color)

    # 蝴蝶飞行
    bx += (tx - bx) * 0.12
    by += (ty - by) * 0.12

    # 翅膀扇动
    flap = math.sin(frame * 0.3) * 10

    # 画完整蝴蝶
    drawButterfly(bx, by, flap)

    tur.update()
    tur.ontimer(animate, 30)


def main():
    # ===================== 窗口 =====================
    tur.setup(1000, 700)
    tur.title("🦋 漂亮蝴蝶 - 会飞 + 扇动翅膀 + 星光闪烁")
    tur.bgcolor("#050a15")
    tur.tracer(0)
    tur.width(2)
    tur.hideturtle()

    # ===================== 星光(永久闪烁) =====================
    for _ in range(200):
        t = tur.Turtle()
        t.hideturtle()
        t.penup()
        t.goto(random.randint(-480, 480), random.randint(-320, 320))
        size = random.uniform(1.5, 4)
        color = random.choice(["white", "#cceeff", "#e6ccff", "#fff9cc"])
        stars.append([t, size, color, random.uniform(0, 6.28)])

# ===================== 主程序 =====================
if __name__ == '__main__':

    main()

    tur.onscreenclick(on_click)

    # ===================== 启动 =====================
    animate()
    tur.done()