Welcome to mirror list, hosted at ThFree Co, Russian Federation.

luminance.coffee « conversions « src « chroma-js « node_modules - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dc73e7c0efabe793bec87319db0f43a8b30b0530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

luminance = (r,g,b) ->
    # relative luminance
    # see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
    [r,g,b] = unpack arguments
    r = luminance_x r
    g = luminance_x g
    b = luminance_x b
    0.2126 * r + 0.7152 * g + 0.0722 * b


luminance_x = (x) ->
    x /= 255
    if x <= 0.03928 then x/12.92 else Math.pow((x+0.055)/1.055, 2.4)