我如何用魔杖绘制颜色和半透明的界线
我使用诸如打击之类的代码在我的图片上绘制半透明的黑色框架,边框宽度5像素。
from wand.color import Color
from wand.image import Image
from wand.display import display
from wand.drawing import Drawing
# ... init image
with (Drawing() as draw):
draw.stroke_width = 5
draw.fill_color = Color('transparent')
draw.stroke_color = Color('rgb(0, 0, 0, 0.5)')
draw.rectangle(left=frame_offset, top=frame_offset,
right=w-frame_offset, bottom=h-frame_offset)
但是颜色('rgb(0,0,0,0.5)')
给出了固体黑色边框,而不是预期的半透明。
我在没有成功的情况下尝试了颜色构造器中的alpha设置的某些值,并且在文档中没有关于它的描述。谁能给出一些建议?
I use the code like blow to draw a semi-transparent black frame on my picture, border width 5 pixels.
from wand.color import Color
from wand.image import Image
from wand.display import display
from wand.drawing import Drawing
# ... init image
with (Drawing() as draw):
draw.stroke_width = 5
draw.fill_color = Color('transparent')
draw.stroke_color = Color('rgb(0, 0, 0, 0.5)')
draw.rectangle(left=frame_offset, top=frame_offset,
right=w-frame_offset, bottom=h-frame_offset)
But the Color('rgb(0, 0, 0, 0.5)')
gives a solid black border, not semi-transparent as expected.
I had tried some value of the alpha setting in color constructor without successful, and in document of wand
there is no description about it. Can anyone give some advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
rgb
颜色定义后,您缺少a
。只需将draws.stroke_color
属性更新为rgba(0,0,0,0,0.5)
。You're missing the
a
afterrgb
color definition. Just update theDrawing.stroke_color
property torgba(0, 0, 0, 0.5)
.