View Source Ultraviolet.Color.HSV (Ultraviolet v0.1.1)

Functions for working in the HSV color space

Summary

Types

t()

Defines the channels in an HSV / HSB color.

Functions

Converts a Color to HSV

Generates a new HSV color object

Generates a new HSV color object

Generates a new HSV color object

Converts from HSV to an RGB Color object

Types

@type t() :: %Ultraviolet.Color.HSV{
  a: number(),
  h: number(),
  s: number(),
  v: number()
}

Defines the channels in an HSV / HSB color.

Functions

Link to this function

from_rgb(color, options \\ [])

View Source
@spec from_rgb(Ultraviolet.Color.t(), list()) :: {:ok, t()}

Converts a Color to HSV

Options

  • :round: an integer if rounding r, g, and b channel values to N decimal places is desired; if no rounding is desired, pass false. Default: 0
@spec new(tuple() | [number()] | map() | [...]) :: {:ok, t()}

Generates a new HSV color object

iex>Ultraviolet.Color.HSV.new({60, 0.0, 0.5})
{:ok, %Ultraviolet.Color.HSV{h: 60, s: 0.0, v: 0.5}}
@spec new(number(), number(), number()) :: {:ok, t()}

Generates a new HSV color object

iex>Ultraviolet.Color.HSV.new(60, 0.0, 0.5)
{:ok, %Ultraviolet.Color.HSV{h: 60, s: 0.0, v: 0.5}}
@spec new(number(), number(), number(), number()) :: {:ok, t()}

Generates a new HSV color object

iex>Ultraviolet.Color.HSV.new(60, 0.0, 0.5, 0.5)
{:ok, %Ultraviolet.Color.HSV{h: 60, s: 0.0, v: 0.5, a: 0.5}}
@spec to_rgb(t()) :: {:ok, Ultraviolet.Color.t()}

Converts from HSV to an RGB Color object

Options

  • :round: an integer if rounding r, g, and b channel values to N decimal places is desired; if no rounding is desired, pass false. Default: 0
@spec to_rgb(t(), list()) :: {:ok, Ultraviolet.Color.t()}