diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2024-11-13 02:33:07 -0500 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2024-11-13 02:33:07 -0500 |
commit | 74a8430a3334570e1dce4c112b166c80923f8402 (patch) | |
tree | 75d8a7501eb0e42ca4d026db0516d012dba91183 /scripts | |
parent | ff981cd5b7ab9274630a1417593af96e36b99e7a (diff) |
Fixes for vector magnitude in color widget
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/gui-common/widgets.js | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/scripts/gui-common/widgets.js b/scripts/gui-common/widgets.js index 9ec1712..bedbc11 100644 --- a/scripts/gui-common/widgets.js +++ b/scripts/gui-common/widgets.js @@ -584,16 +584,12 @@ class WidgetColorWheel extends WidgetDragable let rect = this.element.getBoundingClientRect(); // Points - let tmpX = event.clientX; - let tmpY = rect.bottom - event.clientY + rect.top; + let tmpX = event.clientX - rect.width / 2; + let tmpY = rect.bottom - event.clientY + rect.top - rect.height / 2; // Percents - tmpX = (tmpX - rect.left) / (rect.right - rect.left); - tmpY = (tmpY - rect.top) / (rect.bottom - rect.top); - - // Vecs - tmpX = (Math.min(Math.max(0.0, tmpX), 1.0) - 0.5) * 2; - tmpY = (Math.min(Math.max(0.0, tmpY), 1.0) - 0.5) * 2; + tmpX = (tmpX - rect.left) / ((rect.right - rect.left) / 2); + tmpY = (tmpY - rect.top) / ((rect.bottom - rect.top) / 2); // Normalized let mag = Math.sqrt(tmpX * tmpX + tmpY * tmpY); @@ -601,6 +597,7 @@ class WidgetColorWheel extends WidgetDragable { tmpX /= mag; tmpY /= mag; + mag = 1; } this.element.style.setProperty("--pos-x", tmpX); |