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)

Bases: AppliedGroup

Create a masking effect using shape as the outline

For the passed items, only the parts inside the shape will be shown

Parameters:
  • shape – Mask shape; if it has descendant items, the descendant shapes are combined using XOR

  • alpha – Overall mask opacity, in the range 0.0 ~ 1.0

  • feather – Edge feather size; the larger the value, the blurrier it becomes; numerically, it is reflected as the distance on both sides of the feathered region

  • invert – Invert the mask; 0.0 is normal and 1.0 is fully inverted

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

If you want shape to use the union of its descendant items, see from_group(), for example:

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

Nested masks, like FrameEffect, require explicitly nesting ShapeMask objects:

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

alias of ShapeMaskRenderer

points
alpha
feather
invert