Python海龟不透明度? [英] Python Turtle Opacity?
本文介绍了Python海龟不透明度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
只是想知道,是否可以用半透明墨水绘制/填充乌龟?
Just wondering, is it possible to make a turtle draw/fill with semi-transparent ink?
类似于:
turtle.setfillopacity(50) # Would set it to 50% transparency
运行 python 2.7
Running python 2.7
推荐答案
好吧,你可以使用RGBA.
首先,放入正常语句:
Well, you can use RGBA.
First, put in the normal statements:
导入海龟
t = turtle.Turtle()
然后,使用t.color()
,但使用RGBA.
RGBA的第一部分与RGB相同,最后一个值是不透明度的百分比(其中0为透明,1为不透明.)
Then, use t.color()
, but use RGBA.
The first portion of RGBA is the same as RGB, and the last value is the percentage of opacity (where 0 is transparent, 1 is opaque.)
t.color(0,0,0,.5)
会以 50% 的不透明度为您呈现黑色.
will get you black with 50% opacity.
这篇关于Python海龟不透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文