Bug 203695 - Web Inspector: Color picker: incorrect saturation when selecting color on color square
Summary: Web Inspector: Color picker: incorrect saturation when selecting color on col...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nikita Vasilyev
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-10-31 13:43 PDT by Nikita Vasilyev
Modified: 2019-10-31 15:26 PDT (History)
4 users (show)

See Also:


Attachments
[Image] Bug (247.58 KB, image/png)
2019-10-31 13:43 PDT, Nikita Vasilyev
no flags Details
Patch (5.93 KB, patch)
2019-10-31 13:49 PDT, Nikita Vasilyev
mattbaker: review+
Details | Formatted Diff | Diff
Patch (5.98 KB, patch)
2019-10-31 14:37 PDT, Nikita Vasilyev
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2019-10-31 13:43:57 PDT
Created attachment 382496 [details]
[Image] Bug

For instance, the top middle point of the color square should have:

100% saturation
75% lightness

Instead, it shows:

50% saturation
75% lightness
Comment 1 Radar WebKit Bug Importer 2019-10-31 13:44:09 PDT
<rdar://problem/56793697>
Comment 2 Nikita Vasilyev 2019-10-31 13:49:21 PDT
Created attachment 382498 [details]
Patch
Comment 3 Matt Baker 2019-10-31 14:29:46 PDT
Comment on attachment 382498 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=382498&action=review

r=me, looks good!

> Source/WebInspectorUI/UserInterface/Models/Color.js:270
> +    }

Per our offline discussion, I agree that this reads closer to the conversion algorithm on Wikipedia:

static hsv2hsl(h, s, v)
{
    h = Number.constrain(h, 0, 360);
    s = Number.constrain(s, 0, 100) / 100;
    v = Number.constrain(v, 0, 100) / 100;

    let l = v - v * s / 2;
    let s;
    if (l === 0 || l === 1)
        s = 0;
    else
        s = (v - l) / Math.min(l, 1 - l);

    return [h, s * 100, l * 100];
}
Comment 4 Nikita Vasilyev 2019-10-31 14:37:00 PDT
Created attachment 382502 [details]
Patch
Comment 5 WebKit Commit Bot 2019-10-31 15:26:19 PDT
Comment on attachment 382502 [details]
Patch

Clearing flags on attachment: 382502

Committed r251885: <https://trac.webkit.org/changeset/251885>
Comment 6 WebKit Commit Bot 2019-10-31 15:26:20 PDT
All reviewed patches have been landed.  Closing bug.