You are using the new UI (Beta).Return to the original UI

This page has been automatically translated by machine translation. Please note that translations may not be entirely accurate.

keisanHigh-precision calculations for everyday life and work

Calculating Natural Luminance (HSL Color Space) | Law of Light Attenuation

Author: Yoshi1610Executions: 133

※ This library was created by a member. This site is not responsible for its content.

Manage Bookmarks
Calculates a brightness (with endpoints specified by constants) that looks natural for any distance within the interval.
Please feel free to use this for CSS `hsla()` in dark themes as well.
(This is not a simple inverse proportion! It appropriately corrects for the inverse square law.)
Luminance is a value representing brightness in color spaces such as HSL (Hue, Saturation, Luminance), and ranges from 0 (pure black) to 1 (pure white).

The constants a and b are values such that 0 < a ≤ b ≤ 1, representing the minimum (a) and maximum (b) values of the calculated luminance.
The variable `x0` is the initial value of the variable `x` in the calculation formula, where 0 < `x0` ≤ 1.
`x0` represents the initial value of the proportion of the distance measured from `a` toward `b` within the range between `a` and `b`.
For example, if x0 = 0.5, the initial value is set to the distance exactly halfway between the distances corresponding to luminance values a and b.
The variable xI is the increment for x0 in the loop; it is added to x0 repeatedly until it exceeds 1.
a
(Minimum Luminance)
b(Maximum Luminance)
x0
0 Recommended (default value for distance ratio)
xI
(The increment value of x0 is repeatedly added to x0 until it exceeds 1.)
If an invalid value is specified, the calculation may not produce the correct result.
The calculation formula uses the law of light attenuation.
Calculation formula used:
1 / ( ((1/a)^(1/2) - ((1/b)^(1/2)))*x + ((1/b)^(1/2)))^2

No customer feedback for this calculation yet.