From ee88a2c74c8b54e89ba03ef1531759fedb423ae7 Mon Sep 17 00:00:00 2001 From: Ergun Erdogmus Date: Wed, 25 Jan 2023 16:21:40 +0100 Subject: [PATCH] Fix not finishing the sRGB line on hue around 246 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: 1408777 Change-Id: I3147c576e70fa9ef7276c350a72b688eecb9f714 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4194331 Reviewed-by: Philip Pfaffe Commit-Queue: Philip Pfaffe Auto-Submit: Ergün Erdoğmuş Commit-Queue: Ergün Erdoğmuş --- .../ui/components/srgb_overlay/SrgbOverlay.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/front_end/ui/components/srgb_overlay/SrgbOverlay.ts b/front_end/ui/components/srgb_overlay/SrgbOverlay.ts index 3cb19c110f..ca1d30ba98 100644 --- a/front_end/ui/components/srgb_overlay/SrgbOverlay.ts +++ b/front_end/ui/components/srgb_overlay/SrgbOverlay.ts @@ -63,6 +63,18 @@ export class SrgbOverlay extends HTMLElement { } } + if (linePoints.length === 0) { + return null; + } + + const lastPoint = linePoints[linePoints.length - 1]; + if (lastPoint.x < width) { + linePoints.push({ + y: lastPoint.y, + x: width, + }); + } + return linePoints; } @@ -70,7 +82,7 @@ export class SrgbOverlay extends HTMLElement { let min = Infinity; let closestPoint = null; for (const point of points) { - if (Math.abs(atHeight - point.y) < min) { + if (Math.abs(atHeight - point.y) <= min) { min = Math.abs(atHeight - point.y); closestPoint = point; }