Experimental masking helpers for Blendend.Canvas.
Examples
alias Blendend.{Canvas, Canvas.Mask, Style.Color, Image}
mask = Image.from_file_a8!("priv/images/splash.png", :red)
{mw, mh} = Image.size!(mask)
canvas =
Canvas.new!(mw, mh)
|> Canvas.clear!()
:ok =
Mask.fill(canvas, mask, 0, 0,
color: Color.rgb!(255, 200, 255),
alpha: 1.0
)
:ok = Canvas.save!(canvas, "priv/images/masked_canvas.png")To blur a mask (e.g. soft shadows), use blur_fill/6 and set sigma in pixels.
A sigma of 3.0 produces a visible blur radius around ~9 px.
Summary
Functions
Blurs a mask image with sigma and fills it at {x, y}.
Same as blur_fill/6, but raises and returns the canvas on success.
Fills using the current style through an image mask anchored at {x, y}.
x and y are numbers.
Same as fill/5, but raises Blendend.Error on failure and returns
the canvas for use in pipelines.
Types
@type canvas() :: Blendend.Canvas.t()
@type image() :: Blendend.Image.t()
Functions
@spec blur_fill(canvas(), image(), number(), number(), number(), keyword()) :: :ok | {:error, term()}
Blurs a mask image with sigma and fills it at {x, y}.
Returns :ok on success or {:error, reason}. Uses the same options as fill/5.
Same as blur_fill/6, but raises and returns the canvas on success.
Fills using the current style through an image mask anchored at {x, y}.
x and y are numbers.
On success returns :ok. On failure returns {:error, reason}.
Same as fill/5, but raises Blendend.Error on failure and returns
the canvas for use in pipelines.