RESOLVED FIXED 189485
Web Inspector: change WI.ColorWheel to use conic-gradient()
https://bugs.webkit.org/show_bug.cgi?id=189485
Summary Web Inspector: change WI.ColorWheel to use conic-gradient()
Devin Rousso
Reported 2018-09-10 15:37:52 PDT
Now that conic-gradient() is supported, we don't need to have three different canvases to generate the color wheel, especially since we don't actually use the pixel values of the canvas when we generate the resulting color value.
Attachments
Patch (13.15 KB, patch)
2018-09-10 15:41 PDT, Devin Rousso
no flags
[Image] After Patch is applied (204.31 KB, image/png)
2018-09-10 15:42 PDT, Devin Rousso
no flags
[Image] ColorWheel in shipping Safari (138.87 KB, image/png)
2018-09-10 17:47 PDT, Matt Baker
no flags
[Image] ColorWheel w/ patch applied (78.34 KB, image/png)
2018-09-10 17:47 PDT, Matt Baker
no flags
Patch (27.43 KB, patch)
2018-10-25 15:31 PDT, Devin Rousso
no flags
Patch (27.51 KB, patch)
2018-10-30 14:37 PDT, Devin Rousso
no flags
Devin Rousso
Comment 1 2018-09-10 15:41:40 PDT
Devin Rousso
Comment 2 2018-09-10 15:42:04 PDT
Created attachment 349339 [details] [Image] After Patch is applied
Matt Baker
Comment 3 2018-09-10 17:46:39 PDT
Comment on attachment 349338 [details] Patch r-, because it looks like this patch changes the behavior of the wheel. For example, try the following in shipping Safari and with this patch applied: 1. Bring up the color picker 2. Enter 255 for each channel, in order: R, then, G, then B. 3. Note the "crosshairs" location, and color wheel appearance. See attached screenshots.
Matt Baker
Comment 4 2018-09-10 17:47:39 PDT
Created attachment 349364 [details] [Image] ColorWheel in shipping Safari
Matt Baker
Comment 5 2018-09-10 17:47:55 PDT
Created attachment 349365 [details] [Image] ColorWheel w/ patch applied
Devin Rousso
Comment 6 2018-09-10 18:58:45 PDT
(In reply to Matt Baker from comment #3) > r-, because it looks like this patch changes the behavior of the wheel. For > example, try the following in shipping Safari and with this patch applied: > > 1. Bring up the color picker > 2. Enter 255 for each channel, in order: R, then, G, then B. > 3. Note the "crosshairs" location, and color wheel appearance. > > See attached screenshots. I definitely should've added this to the ChangeLog, but this patch does definitively change the functionality of `WI.ColorWheel`. Our previous implementation used a RGB-esque color space, whereas this version follows an HSL color space. I personally find HSL to be easier to understand over RGB. In the RGB version, there is no clear explanation as to how the individual R, G, and B values map onto the visible colors, except that there are three "hot corners" for each of red, green, and blue. The HSL version, however, is much more straightforward to how HSL works, in that H is represented by the angle around the center, S is how far from the center, and L is the slider on the right. Additionally, this vastly simplifies the logic for determining the color from a position inside `WI.ColorWheel`. I personally think that this is a much clearer and simpler version.
Blaze Burg
Comment 7 2018-09-10 20:56:26 PDT
+1 to replacing with HSL-based picker. However, you should retitle the bug, if not at least mention it in the ChangeLog. This is something we'll need to update documentation for.
Matt Baker
Comment 8 2018-09-11 12:45:18 PDT
(In reply to Devin Rousso from comment #6) > (In reply to Matt Baker from comment #3) > > r-, because it looks like this patch changes the behavior of the wheel. For > > example, try the following in shipping Safari and with this patch applied: > > > > 1. Bring up the color picker > > 2. Enter 255 for each channel, in order: R, then, G, then B. > > 3. Note the "crosshairs" location, and color wheel appearance. > > > > See attached screenshots. > I definitely should've added this to the ChangeLog, but this patch does > definitively change the functionality of `WI.ColorWheel`. Our previous > implementation used a RGB-esque color space, whereas this version follows an > HSL color space. I personally find HSL to be easier to understand over RGB. > In the RGB version, there is no clear explanation as to how the individual > R, G, and B values map onto the visible colors, except that there are three > "hot corners" for each of red, green, and blue. The HSL version, however, > is much more straightforward to how HSL works, in that H is represented by > the angle around the center, S is how far from the center, and L is the > slider on the right. Additionally, this vastly simplifies the logic for > determining the color from a position inside `WI.ColorWheel`. I personally > think that this is a much clearer and simpler version. I agree HSL is easier to conceptualize. Do the input labels need to be updated to H, S, L?
Devin Rousso
Comment 9 2018-09-11 14:49:48 PDT
(In reply to Matt Baker from comment #8) > I agree HSL is easier to conceptualize. Do the input labels need to be > updated to H, S, L? The input labels are based on the current format of the color text, not the `WI.ColorWheel` (e.g. if you click on `rgb(...)`, it'll show R, G, and B inputs, whereas clicking on `hsla()` will show H, S, L, and A inputs).
Devin Rousso
Comment 10 2018-10-25 15:31:22 PDT
Blaze Burg
Comment 11 2018-10-30 13:15:46 PDT
Comment on attachment 353115 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=353115&action=review r=me > Source/WebInspectorUI/UserInterface/Views/ColorPicker.js:104 > + WI.ColorPicker._supportsConicGradient = window.getComputedStyle(element).getPropertyValue(property).includes(conicGradient); You are clever. > Source/WebInspectorUI/UserInterface/Views/ColorPicker.js:234 > + brightnessGradient = "linear-gradient(90deg, black, " + rawColor + ", white)"; Nit; Using template literals would be nice here > Source/WebInspectorUI/UserInterface/Views/ColorWheel.js:41 > + this._crosshair = this._element.appendChild(document.createElement("div")); Nit: _crosshairElement > Source/WebInspectorUI/UserInterface/Views/ColorWheel.js:157 > + var point = window.webkitConvertPointFromPageToNode(this._gradientElement, new WebKitPoint(event.pageX, event.pageY)); I've never heard of this before. > Source/WebInspectorUI/UserInterface/Views/ColorWheel.js:169 > + if (center.distance(point) > radius) { It would be nice to add a comment that this branch handles snapping to the edge when the event is outside of the picker circle.
Devin Rousso
Comment 12 2018-10-30 14:37:13 PDT
Comment on attachment 353115 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=353115&action=review >> Source/WebInspectorUI/UserInterface/Views/ColorWheel.js:157 >> + var point = window.webkitConvertPointFromPageToNode(this._gradientElement, new WebKitPoint(event.pageX, event.pageY)); > > I've never heard of this before. ¯\_(ツ)_/¯ <https://developer.apple.com/documentation/webkitjs/domwindow/1631559-webkitconvertpointfrompagetonode> This was what was used before :P
Devin Rousso
Comment 13 2018-10-30 14:37:51 PDT
WebKit Commit Bot
Comment 14 2018-10-30 15:15:23 PDT
Comment on attachment 353410 [details] Patch Clearing flags on attachment: 353410 Committed r237605: <https://trac.webkit.org/changeset/237605>
WebKit Commit Bot
Comment 15 2018-10-30 15:15:25 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 16 2018-10-30 15:16:51 PDT
Note You need to log in before you can comment on or make changes to this bug.