pyx模块:如何使颜色透明

2024-04-26 09:39:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我试过了(但失败了!)得到^{}在矩形上画一个透明圆。在

手册中有一个关于^{}的条目,但我无法想出如何使用它。matplotlib将使用alpha来实现这一点,但我在pyx文档中找不到这样的条目。在

在我的例子中,我试图在一个实心矩形上画一个蓝色的透明圆环。有人知道怎么做吗?在

from pyx import canvas, path, color
from pathlib import Path

HERE = Path(__file__).parent

out_path = HERE / 'pyx_test'

c = canvas.canvas()
c.fill(path.rect(-5, -5, 10, 10), [color.rgb.red])
# color.transparency(value) ...?
c.fill(path.circle(0, 0, 6), [color.rgb.blue])
c.writePDFfile(str(out_path))
print('wrote "{}"'.format(out_path))

Tags: pathfromimportherematplotlib条目rgb手册
1条回答
网友
1楼 · 发布于 2024-04-26 09:39:10

颜色透明度应与填充方法一起传递。在

你可以试试这个:

from pyx import canvas, path, color
from pathlib import Path

HERE = Path(__file__).parent

out_path = HERE / 'pyx_test'

c = canvas.canvas()
c.fill(path.rect(-5, -5, 10, 10), [color.rgb.red])
c.fill(path.circle(0, 0, 6), [color.rgb.blue,color.transparency(0.75)])
c.writePDFfile(str(out_path))
print('wrote "{}"'.format(out_path))

相关问题 更多 >