Image.BlendMode (image v0.62.0)
View SourceFunctions to define and validate the blending modes that can be applied when composing images.
Summary
Types
Blend mode to use when compositing images. See Image.compose/3.
Functions
Returns the default blend mode
Returns the known blending modes.
Normalizes and validates a blend mode.
Types
@type t() ::
:exclusion
| :soft_light
| :hard_light
| :colour_burn
| :colour_dodge
| :lighten
| :darken
| :screen
| :saturate
| :dest_atop
| :dest_out
| :dest_in
| :dest_over
| :atop
| :over
| :overlay
| :multiply
| :dest
| :source
| :difference
| :add
| :xor
| :out
| :in
| :clear
Blend mode to use when compositing images. See Image.compose/3.
:overthe image shows what you would expect if you held two semi-transparent slides on top of each other. This is the default when composing images:clearwhere the second image is drawn, the first is removed:sourcethe second image is drawn as if nothing were below:inthe first image is removed completely, the second is only drawn where the first was:outthe second is drawn only where the first isn't:atopthis leaves the first image mostly intact, but mixes both images in the overlapping area:destleaves the first image untouched, the second is discarded completely:dest_overlike:over, but swaps the arguments:dest_inlike:in, but swaps the arguments:dest_outlike:out, but swaps the arguments:dest_atoplike:atop, but swaps the arguments:xorsomething like a difference operator:adda bit like adding the two images:saturatea bit like the darker of the two:multiplyat least as dark as the darker of the two inputs:screenat least as light as the lighter of the inputs:overlaymultiplies or screens colors, depending on the lightness:darkenthe darker of each component:lightenthe lighter of each component:colour_dodgebrighten first by a factor second:colour_burndarken first by a factor of second:hard_lightmultiply or screen, depending on lightness:soft_lightdarken or lighten, depending on lightness:differencedifference of the two:exclusionsomewhat like :difference, but lower-contrast
Functions
Returns the default blend mode
Example
iex> Image.BlendMode.default_blend_mode
:VIPS_BLEND_MODE_OVER
Returns the known blending modes.
See Image.BlendMode.t/0 for a description
of each mode.
@spec validate_blend_mode(t() | nil) :: {:ok, atom()} | {:error, Image.error_message()}
Normalizes and validates a blend mode.
Argument
blend_modeis one ofImage.BlendMode.known_blend_modes/0as either aString.t/0or anatom.
Returns
{:ok, atom_blend_mode}whereatom_blend_modeis a valid blend mode forlibvips{:error, reason}
Examples
iex> Image.BlendMode.validate_blend_mode :clear
{:ok, :VIPS_BLEND_MODE_CLEAR}
iex> Image.BlendMode.validate_blend_mode "Over"
{:ok, :VIPS_BLEND_MODE_OVER}
iex> Image.BlendMode.validate_blend_mode :VIPS_BLEND_MODE_XOR
{:ok, :VIPS_BLEND_MODE_XOR}
iex> Image.BlendMode.validate_blend_mode :woops
{:error, {:error, "Unknown blend mode. Found :woops"}}