淡入淡出姑娘_turtle+pil实现虚像效果

淡入淡出姑娘_turtle+pil实现虚像效果

python turtle fade in fade out effect maid淡入淡出的姑娘演示

python turtle fade in fade out effect maid淡入淡出的姑娘演示

python turtle fade in fade out effect maid淡入淡出的姑娘演示


江南姑娘在古镇若隐若现。以下是部分代码预览:

"""
   淡入淡出姑娘.py
   曾经以为海龟画图不能支持虚像效果,其实这是对的。
   但这并不意味着不能显示透明图形,本程序配合PIL模块的相关命令,
   让海龟画图屏幕显示一张淡入淡出的姑娘图形,并且图形会跟随着鼠标指针移动。
   
"""
from PIL import Image,ImageTk
from turtle import Turtle,Screen,TurtleScreenBase,Shape

def _onmousemove(self, fun, add=None):
    """绑定鼠标移动事件"""    
    pass

def follow(x,y):
    pass
    
def setalpha(turtle,alpha):
    """turtle:海龟对象,alpha:透明度"""    
    pass
    
width,height = 800,500
screen = Screen()
screen.delay(0)
screen.setup(width,height)
screen.bgpic("zhouzhuang.png")
screen.title("淡入淡出姑娘by李兴球")

filename = '姑娘.png'
pass
maid = Turtle(visible=False,shape=filename)
maid.rawimagename = filename
maid.rawimage = rawimage
setalpha(maid,0)
screen.onmousemove(follow)
maid.up()
maid.st()

while 1:
    for alpha in range(0,256):
        setalpha(maid,alpha)

    for alpha in range(255,-1,-1):
        setalpha(maid,alpha)


如需要下载完整源代码及素材,请

成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

李兴球

李兴球的博客是Python创意编程原创博客

评论已关闭。