This module contains functions to add effects to geometries.
It currently provides gaussian blur filter and shadow effects on top of it. The NIF implementation is based on https://blog.ivank.net/fastest-gaussian-blur.html.
Gaussian blur is applied after rasterizing a path into an offscreen image,
then composited back on the destination canvas. So applying a blur to a
shape is more expensive than most other operations in blendend.
Examples:
use Blendend.Draw
clear(fill: rgb(0x42, 0x4D, 0x8C))
ring =
path do
add_circle(220, 210, 96.0)
end
blur_path(ring, 4,
mode: :stroke,
stroke: rgb(90, 200, 255),
stroke_width: 10.0
)
Summary
Functions
Render a blurred copy of path onto canvas.
Same as blur_path/4, but raises on failure and returns the canvas.
Blur a path with an offset to create a soft shadow or glow.
Same as shadow_path/6, but raises on failure and returns the canvas.
Types
Functions
@spec blur_path(Blendend.Canvas.t(), Blendend.Path.t(), number(), keyword()) :: :ok | {:error, term()}
Render a blurred copy of path onto canvas.
sigmacontrols blur strength in pixels (roughlyradius = 3 * sigma).- options:
:mode–:fill,:stroke, or:both(alias:fill_and_stroke); (defaults to fill if none set):offset–{dx, dy}translation before compositing (useful for shadows); values are floats:resolution– scale factor0 < r ≤ 1.0to render/blur (If blurring feels slow, tune this down. Defaults to 1.0)
@spec blur_path!(Blendend.Canvas.t(), Blendend.Path.t(), number(), keyword()) :: Blendend.Canvas.t()
Same as blur_path/4, but raises on failure and returns the canvas.
@spec shadow_path( Blendend.Canvas.t(), Blendend.Path.t(), number(), number(), number(), keyword() ) :: :ok | {:error, term()}
Blur a path with an offset to create a soft shadow or glow.
dx/dy shift the blurred image; other options are forwarded to blur_path/4.
@spec shadow_path!( Blendend.Canvas.t(), Blendend.Path.t(), number(), number(), number(), keyword() ) :: Blendend.Canvas.t()
Same as shadow_path/6, but raises on failure and returns the canvas.