earmark_tag_cloud v0.1.3 EarmarkTagCloud.GammaCorrection
Link to this section Summary
Functions
Make an RGB string for the given gray_scale of a number of scales and a given gamma correction according to this formula
Link to this section Functions
Link to this function
make_gray(gray_scale, map)
Make an RGB string for the given gray_scale of a number of scales and a given gamma correction according to this formula:
255 * ( gray_scale / scales ) ^ ( 1 / gamma )
Gamma defaults to 2.2 and you should only change it if the results are not satisfactory.
See the following Wikipedia article for more information.
Therefore
iex> make_gray(99, %{"scales" => 100, "gamma" => 2.2})
{:ok, "1f1f1f"}
iex> make_gray(0, %{"scales" => 100, "gamma" => 2.2})
{:ok, "ffffff"}
iex> make_gray(10, %{"scales" => 12, "gamma" => 2.2})
{:ok, "717171"}
iex> make_gray(13, %{"scales" => 12, "gamma" => 2.2})
{:error, "value for gray-scale out of legal range. Actual: 13, Allowed: 0..12"}
Or, if you must
iex> make_gray(42, %{"scales" => 99, "gamma" => 1.9})
{:ok, "bfbfbf"}