soiz1 commited on
Commit
ef72236
·
verified ·
1 Parent(s): e951be4

Update src/addons/addons/paint-gradient-maker/userscript.js

Browse files
src/addons/addons/paint-gradient-maker/userscript.js CHANGED
@@ -160,9 +160,14 @@ export default async function () {
160
  modalStorage.dir = settings.dir;
161
  }
162
 
163
- function handleFillEvent() {
164
  if (!modalStorage._gradCache) return;
165
 
 
 
 
 
 
166
  // set the swatch color in case the GUI resets it
167
  const swatch = document.querySelector(`div[class^=color-button_color-button_] div[class^=color-button_color-button-swatch_]`);
168
  if (swatch) queueMicrotask(() => {
@@ -591,7 +596,7 @@ export default async function () {
591
  }
592
 
593
  // run relative tool events
594
- if (mode === "FILL") handleFillEvent();
595
  else if (paperLinkModes.has(mode)) handleShapeModeEvent(mode);
596
 
597
  const idChain = selectedItems.map((e) => e.id).join(".");
@@ -628,6 +633,7 @@ export default async function () {
628
  customBtn.setAttribute("class", selectedClassName);
629
  openGradientMaker();
630
  } else if (e.target.nodeName === "IMG") {
 
631
  customBtn.setAttribute("class", unselectedClassName);
632
  }
633
  });
 
160
  modalStorage.dir = settings.dir;
161
  }
162
 
163
+ function handleFillEvent(paint) {
164
  if (!modalStorage._gradCache) return;
165
 
166
+ // set the GUI gradient mode to linear so we can position our gradients
167
+ paint.fillMode.gradientType = "HORIZONTAL";
168
+ paint.color.fillColor.gradientType = "HORIZONTAL";
169
+ paint.color.strokeColor.gradientType = "HORIZONTAL";
170
+
171
  // set the swatch color in case the GUI resets it
172
  const swatch = document.querySelector(`div[class^=color-button_color-button_] div[class^=color-button_color-button-swatch_]`);
173
  if (swatch) queueMicrotask(() => {
 
596
  }
597
 
598
  // run relative tool events
599
+ if (mode === "FILL") handleFillEvent(paint);
600
  else if (paperLinkModes.has(mode)) handleShapeModeEvent(mode);
601
 
602
  const idChain = selectedItems.map((e) => e.id).join(".");
 
633
  customBtn.setAttribute("class", selectedClassName);
634
  openGradientMaker();
635
  } else if (e.target.nodeName === "IMG") {
636
+ modalStorage._gradCache = undefined;
637
  customBtn.setAttribute("class", unselectedClassName);
638
  }
639
  });