mask

class janim.items.effect.mask.ShapeMask(*items, shape: Item, alpha: float = 1.0, feather: float = 0.0, invert: bool = False, root_only: bool = False, **kwargs)

基类:AppliedGroup

shape 为轮廓做一个蒙板效果

对于传入的物件,只会显示形状内部的部分

参数:
  • shape -- 蒙板图形,若带有后代物件,则将若干后代物件图形作 XOR

  • alpha -- 蒙板整体透明度,范围 0.0 ~ 1.0

  • feather -- 边缘羽化大小,值越大越模糊;数值上体现为羽化部分的两侧的距离

  • invert -- 反转蒙板, 0.0 为正常, 1.0 为完全反转

text = Text('Hello').show()
mask = ShapeMask(text, shape=Circle(radius=2), feather=0.2)
mask.show()

shape 要使用后代物件的并,可参考 from_group() ,例如

ShapeMask(..., shape=boolean_ops.Union.from_group(shape))

嵌套蒙板和 FrameEffect 一样,需要显式嵌套 ShapeMask 对象:

mask1 = ShapeMask(..., shape=shape1).show()
mask2 = ShapeMask(mask1, shape=shape2).show()
renderer_cls

ShapeMaskRenderer 的别名

points
alpha
feather
invert