【问题标题】:pyx module: how to make color transparentpyx 模块:如何使颜色透明
【发布时间】:2017-05-03 10:38:36
【问题描述】:

我尝试(但失败了!)让pyx 在矩形上绘制一个透明的圆圈。

手册中有一个关于transparency 的条目,但我不知道如何使用它。 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))

【问题讨论】:

    标签: python python-2.7 python-3.x pyx


    【解决方案1】:

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

    你可以试试这个:

    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))
    

    【讨论】:

    猜你喜欢
    • 2012-07-11
    • 2013-06-19
    • 2016-09-02
    • 2021-12-26
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多