plotboilerplate 1.23.0 → 1.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +1 -1
  2. package/dist/index.esm.js +32 -11
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +32 -11
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +3 -1
  11. package/src/cjs/PlotBoilerplate.d.ts +17 -3
  12. package/src/cjs/PlotBoilerplate.js +22 -5
  13. package/src/cjs/PlotBoilerplate.js.map +1 -1
  14. package/src/cjs/drawutilssvg.d.ts +6 -1
  15. package/src/cjs/drawutilssvg.js +10 -6
  16. package/src/cjs/drawutilssvg.js.map +1 -1
  17. package/src/cjs/interfaces/core.d.ts +4 -2
  18. package/src/cjs/interfaces/core.js +1 -0
  19. package/src/cjs/interfaces/core.js.map +1 -1
  20. package/src/cjs/interfaces/externals.d.ts +42 -0
  21. package/src/cjs/utils/InitializationObserver.d.ts +18 -0
  22. package/src/cjs/utils/InitializationObserver.js +63 -0
  23. package/src/cjs/utils/InitializationObserver.js.map +1 -0
  24. package/src/cjs/utils/Params.d.ts +5 -3
  25. package/src/cjs/utils/Params.js +7 -3
  26. package/src/cjs/utils/Params.js.map +1 -1
  27. package/src/cjs/utils/creategui.js +386 -250
  28. package/src/cjs/utils/dat.gui.arrowbounce.polyfill.js +74 -73
  29. package/src/cjs/utils/dat.gui.title.polyfill.js +9 -7
  30. package/src/cjs/utils/dom/guiSizeToggler.d.ts +17 -0
  31. package/src/cjs/utils/dom/guiSizeToggler.js +42 -0
  32. package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -0
  33. package/src/cjs/utils/gup.d.ts +1 -0
  34. package/src/cjs/utils/gup.js +3 -1
  35. package/src/cjs/utils/gup.js.map +1 -1
  36. package/src/cjs/utils/lil.gui.arrowbounce.polyfill.js +133 -0
  37. package/src/cjs/utils/lil.gui.title.polyfill.js +32 -0
  38. package/src/esm/PlotBoilerplate.d.ts +17 -3
  39. package/src/esm/PlotBoilerplate.js +22 -5
  40. package/src/esm/PlotBoilerplate.js.map +1 -1
  41. package/src/esm/drawutilssvg.d.ts +6 -1
  42. package/src/esm/drawutilssvg.js +10 -6
  43. package/src/esm/drawutilssvg.js.map +1 -1
  44. package/src/esm/interfaces/core.d.ts +4 -2
  45. package/src/esm/interfaces/core.js +1 -0
  46. package/src/esm/interfaces/core.js.map +1 -1
  47. package/src/esm/interfaces/externals.d.ts +42 -0
  48. package/src/esm/utils/InitializationObserver.d.ts +18 -0
  49. package/src/esm/utils/InitializationObserver.js +57 -0
  50. package/src/esm/utils/InitializationObserver.js.map +1 -0
  51. package/src/esm/utils/Params.d.ts +5 -3
  52. package/src/esm/utils/Params.js +7 -3
  53. package/src/esm/utils/Params.js.map +1 -1
  54. package/src/esm/utils/dom/guiSizeToggler.d.ts +17 -0
  55. package/src/esm/utils/dom/guiSizeToggler.js +38 -0
  56. package/src/esm/utils/dom/guiSizeToggler.js.map +1 -0
  57. package/src/esm/utils/gup.d.ts +1 -0
  58. package/src/esm/utils/gup.js +3 -1
  59. package/src/esm/utils/gup.js.map +1 -1
  60. package/src/index-gl.js +3 -1
  61. package/src/index.js +2 -1
  62. package/src/ts/PlotBoilerplate.ts +42 -11
  63. package/src/ts/drawutilssvg.ts +17 -6
  64. package/src/ts/interfaces/core.ts +5 -2
  65. package/src/ts/interfaces/externals.ts +50 -0
  66. package/src/ts/utils/InitializationObserver.ts +70 -0
  67. package/src/ts/utils/Params.ts +8 -3
  68. package/src/ts/utils/dom/guiSizeToggler.ts +45 -0
  69. package/src/ts/utils/gup.ts +3 -1
@@ -8,7 +8,9 @@
8
8
  * @date 2020-03-30
9
9
  * @modified 2020-04-03 Added empty default global object 'utils'. Added createGUI as an optional child.
10
10
  * @modified 2023-09-29 Added try-catch for color attributes; invalid values might break construction of whole gui.
11
- * @version 1.0.2
11
+ * @modified 2024-06-25 Replacing dat.gui by equivalent lil-gui calls. Collapsing all lil-gui folders (are open by default).
12
+ * @modified 2024-08-25 Added `CSSBackdropEffects` to the GUI (if present).
13
+ * @version 1.2.0
12
14
  **/
13
15
  var utils = (globalThis.utils = globalThis.utils || {});
14
16
 
@@ -31,268 +33,402 @@ globalThis.utils.guiFolders = globalThis.utils.guiFolders || {};
31
33
  * @method createGUI
32
34
  * @memberof utils
33
35
  * @param {PlotBoilerplate} pb
34
- * @param {DatGuiProps} props
35
- * @return {dat.gui.GUI}
36
+ * @param {DatGuiProps|LilGuiProps} props
37
+ * @return {dat.gui.GUI|lil-gui.GUI|null}
36
38
  **/
37
- globalThis.utils.createGUI = function (pb, props) {
38
- var dummy = {
39
- resetOffset: function () {
40
- var viewport = pb.viewport();
41
- pb.setOffset({ x: (viewport.width / 2.0) * pb.draw.scale.x, y: (viewport.height / 2.0) * pb.draw.scale.y });
42
- pb.redraw();
43
- },
44
- resetScale: function () {
45
- pb.setZoom(1.0, 1.0, new Vertex(0, 0));
46
- pb.redraw();
39
+ globalThis.utils.createGUI = (function () {
40
+ var _tryGetFilterGETParams = function () {
41
+ // Rule is:
42
+ // * GET PARAMS first
43
+ // * pre-defnined params second
44
+ // * default values third
45
+ var globalPredefinedValues =
46
+ typeof globalThis["cssBackdropfilterValues"] === "object" ? globalThis["cssBackdropfilterValues"] : {};
47
+ var preDefinedValues = Object.assign(Object.assign({}, CSSBackdropEffects.DEFAULT_FILTER_VALUES), globalPredefinedValues);
48
+ if (typeof gup === "undefined") {
49
+ return preDefinedValues; // CSSBackdropEffects.DEFAULT_FILTER_VALUES;
47
50
  }
51
+ var GUP = gup();
52
+ var params = new Params(GUP);
53
+ var initialFilterValues = {
54
+ isBackdropFiltersEnabled: false,
55
+ // This is just for the global effect color
56
+ effectFilterColor: params.getString("filter:effectFilterColor", preDefinedValues.effectFilterColor), // "#204a87",
57
+ isEffectsColorEnabled: params.hasParam("filter:effectFilterColor"),
58
+ // These are real filter values
59
+ opacity: params.getNumber("filter:opacity", preDefinedValues.opacity),
60
+ isOpacityEnabled: params.hasParam("filter:opacity") || preDefinedValues.isOpacityEnabled,
61
+ invert: params.getNumber("filter:invert", preDefinedValues.invert),
62
+ isInvertEnabled: params.hasParam("filter:invert") || preDefinedValues.isInvertEnabled,
63
+ sepia: params.getNumber("filter:sepia", preDefinedValues.sepia),
64
+ isSepiaEnabled: params.hasParam("filter:sepia") || preDefinedValues.isSepiaEnabled,
65
+ blur: params.getNumber("filter:blur", preDefinedValues.blur), // px
66
+ isBlurEnabled: params.hasParam("filter:blur") || preDefinedValues.isBlurEnabled,
67
+ brightness: params.getNumber("filter:brightness", preDefinedValues.brightness),
68
+ isBrightnessEnabled: params.hasParam("filter:brightness") || preDefinedValues.isBrightnessEnabled,
69
+ contrast: params.getNumber("filter:contrast", preDefinedValues.contrast),
70
+ isContrastEnabled: params.hasParam("filter:contrast") || preDefinedValues.isContrastEnabled,
71
+ dropShadow: params.getNumber("filter:dropShadow", preDefinedValues.dropShadow), // px
72
+ dropShadowColor: "#00ffff", // HOW TO DISABLE THIS PROPERLY?
73
+ isDropShadowEnabled: params.hasParam("filter:dropShadow") || preDefinedValues.isDropShadowEnabled,
74
+ grayscale: params.getNumber("filter:grayscale", preDefinedValues.grayscale),
75
+ isGrayscaleEnabled: params.hasParam("filter:grayscale") || preDefinedValues.isGrayscaleEnabled,
76
+ hueRotate: params.getNumber("filter:hueRotate", preDefinedValues.hueRotate), // deg
77
+ isHueRotateEnabled: params.hasParam("filter:hueRotate") || preDefinedValues.isHueRotateEnabled,
78
+ saturate: params.getNumber("filter:saturate", preDefinedValues.saturate),
79
+ isSaturateEnabled: params.hasParam("filter:saturate") || preDefinedValues.isSaturateEnabled
80
+ };
81
+ initialFilterValues.isBackdropFiltersEnabled =
82
+ initialFilterValues.isOpacityEnabled ||
83
+ initialFilterValues.isEffectsColorEnabled ||
84
+ initialFilterValues.isInvertEnabled ||
85
+ initialFilterValues.isSepiaEnabled ||
86
+ initialFilterValues.isBlurEnabled ||
87
+ initialFilterValues.isBrightnessEnabled ||
88
+ initialFilterValues.isContrastEnabled ||
89
+ initialFilterValues.isDropShadowEnabled ||
90
+ initialFilterValues.isGrayscaleEnabled ||
91
+ initialFilterValues.isHueRotateEnabled ||
92
+ initialFilterValues.isSaturateEnabled;
93
+
94
+ return initialFilterValues;
48
95
  };
49
96
 
50
- var _self = pb;
51
- var gui = new dat.gui.GUI(props);
52
- gui.remember(pb.config);
53
- var fold0 = gui.addFolder("Editor settings");
54
- var fold00 = fold0.addFolder("Canvas size");
55
- fold00
56
- .add(pb.config, "fullSize")
57
- .onChange(function () {
58
- _self.resizeCanvas();
59
- })
60
- .title("Toggles the fullpage mode.")
61
- .listen();
62
- fold00
63
- .add(pb.config, "fitToParent")
64
- .onChange(function () {
65
- _self.resizeCanvas();
66
- })
67
- .title("Toggles the fit-to-parent mode to fit to parent container (overrides fullsize).")
68
- .listen();
69
- fold00
70
- .add(pb.config, "defaultCanvasWidth")
71
- .min(1)
72
- .step(10)
73
- .onChange(function () {
74
- _self.resizeCanvas();
75
- })
76
- .title("Specifies the fallback width.");
77
- fold00
78
- .add(pb.config, "defaultCanvasHeight")
79
- .min(1)
80
- .step(10)
81
- .onChange(function () {
82
- _self.resizeCanvas();
83
- })
84
- .title("Specifies the fallback height.");
85
- fold00
86
- .add(pb.config, "canvasWidthFactor")
87
- .min(0.1)
88
- .step(0.1)
89
- .max(10)
90
- .onChange(function () {
91
- _self.resizeCanvas();
92
- })
93
- .title("Specifies a factor for the current width.")
94
- .listen();
95
- fold00
96
- .add(pb.config, "canvasHeightFactor")
97
- .min(0.1)
98
- .step(0.1)
99
- .max(10)
100
- .onChange(function () {
101
- _self.resizeCanvas();
102
- })
103
- .title("Specifies a factor for the current height.")
104
- .listen();
105
- fold00
106
- .add(pb.config, "cssScaleX")
107
- .min(0.01)
108
- .step(0.01)
109
- .max(1.0)
110
- .onChange(function () {
111
- if (_self.config.cssUniformScale) _self.config.cssScaleY = _self.config.cssScaleX;
112
- _self.updateCSSscale();
113
- })
114
- .title("Specifies the visual x scale (CSS).")
115
- .listen();
116
- fold00
117
- .add(pb.config, "cssScaleY")
118
- .min(0.01)
119
- .step(0.01)
120
- .max(1.0)
121
- .onChange(function () {
122
- if (_self.config.cssUniformScale) _self.config.cssScaleX = _self.config.cssScaleY;
123
- _self.updateCSSscale();
124
- })
125
- .title("Specifies the visual y scale (CSS).")
126
- .listen();
127
- fold00
128
- .add(pb.config, "cssUniformScale")
129
- .onChange(function () {
130
- if (_self.config.cssUniformScale) _self.config.cssScaleY = _self.config.cssScaleX;
131
- _self.updateCSSscale();
132
- })
133
- .title("CSS uniform scale (x-scale equlsa y-scale).");
134
- fold00.add(pb.config, "setToRetina").name("Set to highres fullsize").title("Set canvas to high-res retina resoultion (x2).");
97
+ var _tryGetGUIInstance = function (props) {
98
+ if (
99
+ globalThis.hasOwnProperty("lil") &&
100
+ typeof globalThis["lil"] == "object" &&
101
+ globalThis["lil"].hasOwnProperty("GUI") &&
102
+ typeof globalThis["lil"]["GUI"] == "function"
103
+ ) {
104
+ // console.log("Creating lil");
105
+ return new lil.GUI(props);
106
+ } else if (
107
+ globalThis.hasOwnProperty("dat") &&
108
+ typeof globalThis["dat"] == "object" &&
109
+ globalThis["dat"].hasOwnProperty("gui") &&
110
+ typeof globalThis["dat"]["gui"] == "object"
111
+ ) {
112
+ // console.log("Creating dat.gui");
113
+ return new dat.gui.GUI(props);
114
+ } else {
115
+ console.warn("Warning: cannot create GUI. Nor dat.gui not lil-gui seem present.");
116
+ return null;
117
+ }
118
+ };
135
119
 
136
- var fold01 = fold0.addFolder("Draw settings");
137
- fold01
138
- .add(pb.drawConfig, "drawBezierHandlePoints")
139
- .onChange(function () {
140
- _self.redraw();
141
- })
142
- .title("Draw Bézier handle points.");
143
- fold01
144
- .add(pb.drawConfig, "drawBezierHandleLines")
145
- .onChange(function () {
146
- _self.redraw();
147
- })
148
- .title("Draw Bézier handle lines.");
149
- fold01
150
- .add(pb.drawConfig, "drawHandlePoints")
151
- .onChange(function () {
152
- _self.redraw();
153
- })
154
- .title("Draw handle points (overrides all other settings).");
155
- fold01
156
- .add(pb.drawConfig, "drawHandleLines")
157
- .onChange(function () {
158
- _self.redraw();
159
- })
160
- .title("Draw handle lines in general (overrides all other settings).");
161
- fold01
162
- .add(pb.drawConfig, "drawVertices")
163
- .onChange(function () {
164
- _self.redraw();
165
- })
166
- .title("Draw vertices in general.");
120
+ var _tryDetectMobileDevice = function () {
121
+ return globalThis.hasOwnProperty("isMobileDevice") && typeof globalThis["isMobileDevice"] == "function" && isMobileDevice();
122
+ };
123
+
124
+ var _tryGetGUISizeToggler = function (gui, dummyConfig) {
125
+ if (!gui) {
126
+ return null;
127
+ }
128
+ if (globalThis.hasOwnProperty("guiSizeToggler") && typeof globalThis["guiSizeToggler"] == "function") {
129
+ return guiSizeToggler(gui, dummyConfig, { transformOrigin: "top right" });
130
+ } else {
131
+ console.warn("Warning: cannot create GUI's double size checkbox. guiSizeToggler is not present.");
132
+ return null;
133
+ }
134
+ };
135
+
136
+ var createGuiFun = function (pb, props) {
137
+ var dummy = {
138
+ resetOffset: function () {
139
+ var viewport = pb.viewport();
140
+ pb.setOffset({ x: (viewport.width / 2.0) * pb.draw.scale.x, y: (viewport.height / 2.0) * pb.draw.scale.y });
141
+ pb.redraw();
142
+ },
143
+ resetScale: function () {
144
+ pb.setZoom(1.0, 1.0, new Vertex(0, 0));
145
+ pb.redraw();
146
+ },
147
+ guiDoubleSize: false
148
+ };
149
+
150
+ // Try to initialise dat.gui (old demos) or lil-gui (new demos). They have the ~same~ signature.
151
+ var gui = _tryGetGUIInstance(props);
152
+ var mobileDevice = _tryDetectMobileDevice();
153
+ var guiSize = _tryGetGUISizeToggler(gui, dummy);
154
+ if (mobileDevice && guiSize) {
155
+ dummy.guiDoubleSize = true;
156
+ guiSize.update();
157
+ }
158
+
159
+ var _self = pb;
160
+ if (guiSize) {
161
+ gui
162
+ .add(dummy, "guiDoubleSize")
163
+ .name("doubleGUISize")
164
+ .onChange(function () {
165
+ guiSize.update();
166
+ });
167
+ }
168
+ var fold0 = gui.addFolder("Editor settings");
169
+ fold0.close(); // important only for lil-gui
170
+ var fold00 = fold0.addFolder("Canvas size");
171
+ fold00.close(); // important only for lil-gui
167
172
 
168
- const fold0100 = fold01.addFolder("Colors and Lines");
169
- const _addDrawConfigElement = function (fold, basePath, conf) {
170
- for (var i in conf) {
171
- if (typeof conf[i] == "object") {
172
- if (conf[i].hasOwnProperty("color")) {
173
- try {
174
- fold
175
- .addColor(conf[i], "color")
176
- .onChange(function () {
177
- _self.redraw();
178
- })
179
- .name(basePath + i + ".color")
180
- .title(basePath + i + ".color")
181
- .listen();
182
- } catch (e) {
183
- console.error("[createGUI] Invalid color value, gui library cannot recognize.", conf[i]["color"]);
173
+ fold00
174
+ .add(pb.config, "fullSize")
175
+ .onChange(function () {
176
+ _self.resizeCanvas();
177
+ })
178
+ .title("Toggles the fullpage mode.")
179
+ .listen();
180
+ fold00
181
+ .add(pb.config, "fitToParent")
182
+ .onChange(function () {
183
+ _self.resizeCanvas();
184
+ })
185
+ .title("Toggles the fit-to-parent mode to fit to parent container (overrides fullsize).")
186
+ .listen();
187
+ fold00
188
+ .add(pb.config, "defaultCanvasWidth")
189
+ .min(1)
190
+ .step(10)
191
+ .onChange(function () {
192
+ _self.resizeCanvas();
193
+ })
194
+ .title("Specifies the fallback width.");
195
+ fold00
196
+ .add(pb.config, "defaultCanvasHeight")
197
+ .min(1)
198
+ .step(10)
199
+ .onChange(function () {
200
+ _self.resizeCanvas();
201
+ })
202
+ .title("Specifies the fallback height.");
203
+ fold00
204
+ .add(pb.config, "canvasWidthFactor")
205
+ .min(0.1)
206
+ .step(0.1)
207
+ .max(10)
208
+ .onChange(function () {
209
+ _self.resizeCanvas();
210
+ })
211
+ .title("Specifies a factor for the current width.")
212
+ .listen();
213
+ fold00
214
+ .add(pb.config, "canvasHeightFactor")
215
+ .min(0.1)
216
+ .step(0.1)
217
+ .max(10)
218
+ .onChange(function () {
219
+ _self.resizeCanvas();
220
+ })
221
+ .title("Specifies a factor for the current height.")
222
+ .listen();
223
+ fold00
224
+ .add(pb.config, "cssScaleX")
225
+ .min(0.01)
226
+ .step(0.01)
227
+ .max(1.0)
228
+ .onChange(function () {
229
+ if (_self.config.cssUniformScale) _self.config.cssScaleY = _self.config.cssScaleX;
230
+ _self.updateCSSscale();
231
+ })
232
+ .title("Specifies the visual x scale (CSS).")
233
+ .listen();
234
+ fold00
235
+ .add(pb.config, "cssScaleY")
236
+ .min(0.01)
237
+ .step(0.01)
238
+ .max(1.0)
239
+ .onChange(function () {
240
+ if (_self.config.cssUniformScale) _self.config.cssScaleX = _self.config.cssScaleY;
241
+ _self.updateCSSscale();
242
+ })
243
+ .title("Specifies the visual y scale (CSS).")
244
+ .listen();
245
+ fold00
246
+ .add(pb.config, "cssUniformScale")
247
+ .onChange(function () {
248
+ if (_self.config.cssUniformScale) _self.config.cssScaleY = _self.config.cssScaleX;
249
+ _self.updateCSSscale();
250
+ })
251
+ .title("CSS uniform scale (x-scale equlsa y-scale).");
252
+ fold00.add(pb.config, "setToRetina").name("Set to highres fullsize").title("Set canvas to high-res retina resoultion (x2).");
253
+
254
+ var fold01 = fold0.addFolder("Draw settings");
255
+ fold01.close(); // important only for lil-gui
256
+
257
+ fold01
258
+ .add(pb.drawConfig, "drawBezierHandlePoints")
259
+ .onChange(function () {
260
+ _self.redraw();
261
+ })
262
+ .title("Draw Bézier handle points.");
263
+ fold01
264
+ .add(pb.drawConfig, "drawBezierHandleLines")
265
+ .onChange(function () {
266
+ _self.redraw();
267
+ })
268
+ .title("Draw Bézier handle lines.");
269
+ fold01
270
+ .add(pb.drawConfig, "drawHandlePoints")
271
+ .onChange(function () {
272
+ _self.redraw();
273
+ })
274
+ .title("Draw handle points (overrides all other settings).");
275
+ fold01
276
+ .add(pb.drawConfig, "drawHandleLines")
277
+ .onChange(function () {
278
+ _self.redraw();
279
+ })
280
+ .title("Draw handle lines in general (overrides all other settings).");
281
+ fold01
282
+ .add(pb.drawConfig, "drawVertices")
283
+ .onChange(function () {
284
+ _self.redraw();
285
+ })
286
+ .title("Draw vertices in general.");
287
+
288
+ const fold0100 = fold01.addFolder("Colors and Lines");
289
+ fold0100.close(); // important only for lil-gui
290
+
291
+ const _addDrawConfigElement = function (fold, basePath, conf) {
292
+ for (var i in conf) {
293
+ if (typeof conf[i] == "object") {
294
+ if (conf[i].hasOwnProperty("color")) {
295
+ try {
296
+ fold
297
+ .addColor(conf[i], "color")
298
+ .onChange(function () {
299
+ _self.redraw();
300
+ })
301
+ .name(basePath + i + ".color")
302
+ .title(basePath + i + ".color")
303
+ .listen();
304
+ } catch (e) {
305
+ console.error("[createGUI] Invalid color value, gui library cannot recognize.", conf[i]["color"]);
306
+ }
184
307
  }
185
- }
186
- // console.log("basePath", basePath, i, conf[i], conf[i].hasOwnProperty("lineWidth"));
187
- if (conf[i].hasOwnProperty("lineWidth")) {
188
- try {
189
- // console.log("adding ", basePath, i);
190
- fold
191
- .add(conf[i], "lineWidth")
192
- .min(1)
193
- .max(10)
194
- .step(1)
195
- .onChange(function () {
196
- _self.redraw();
197
- })
198
- .name(basePath + i + ".lineWidth")
199
- .title(basePath + i + ".lineWidth")
200
- .listen();
201
- // console.log("adding 2", basePath, i);
202
- } catch (e) {
203
- console.error("[createGUI] Invalid lineWidth value, gui library cannot recognize.", conf[i]["lineWidth"]);
308
+ // console.log("basePath", basePath, i, conf[i], conf[i].hasOwnProperty("lineWidth"));
309
+ if (conf[i].hasOwnProperty("lineWidth")) {
310
+ try {
311
+ // console.log("adding ", basePath, i);
312
+ fold
313
+ .add(conf[i], "lineWidth")
314
+ .min(1)
315
+ .max(10)
316
+ .step(1)
317
+ .onChange(function () {
318
+ _self.redraw();
319
+ })
320
+ .name(basePath + i + ".lineWidth")
321
+ .title(basePath + i + ".lineWidth")
322
+ .listen();
323
+ // console.log("adding 2", basePath, i);
324
+ } catch (e) {
325
+ console.error("[createGUI] Invalid lineWidth value, gui library cannot recognize.", conf[i]["lineWidth"]);
326
+ }
204
327
  }
205
- }
206
- for (var e in conf[i]) {
207
- if (conf[i].hasOwnProperty(e) && typeof conf[i][e] == "object") {
208
- // console.log(e);
209
- _addDrawConfigElement(fold, (basePath != "" ? basePath + "." : "") + i + "." + e, conf[i]);
328
+ for (var e in conf[i]) {
329
+ if (conf[i].hasOwnProperty(e) && typeof conf[i][e] == "object") {
330
+ // console.log(e);
331
+ _addDrawConfigElement(fold, (basePath != "" ? basePath + "." : "") + i + "." + e, conf[i]);
332
+ }
210
333
  }
211
334
  }
212
335
  }
336
+ };
337
+ _addDrawConfigElement(fold0100, "", pb.drawConfig);
338
+
339
+ fold0
340
+ .add(pb.config, "scaleX")
341
+ .title("Scale x.")
342
+ .min(0.01)
343
+ .max(10.0)
344
+ .step(0.01)
345
+ .onChange(function () {
346
+ _self.draw.scale.x = _self.fill.scale.x = _self.config.scaleX;
347
+ _self.redraw();
348
+ })
349
+ .listen();
350
+ fold0
351
+ .add(pb.config, "scaleY")
352
+ .title("Scale y.")
353
+ .min(0.01)
354
+ .max(10.0)
355
+ .step(0.01)
356
+ .onChange(function () {
357
+ _self.draw.scale.y = _self.fill.scale.y = _self.config.scaleY;
358
+ _self.redraw();
359
+ })
360
+ .listen();
361
+ fold0
362
+ .add(pb.config, "offsetX")
363
+ .title("Offset x.")
364
+ .step(10.0)
365
+ .onChange(function () {
366
+ _self.draw.offset.x = _self.fill.offset.x = _self.config.offsetX;
367
+ _self.redraw();
368
+ })
369
+ .listen();
370
+ fold0
371
+ .add(pb.config, "offsetY")
372
+ .title("Offset y.")
373
+ .step(10.0)
374
+ .onChange(function () {
375
+ _self.draw.offset.y = _self.fill.offset.y = _self.config.offsetY;
376
+ _self.redraw();
377
+ })
378
+ .listen();
379
+ fold0
380
+ .add(pb.config, "drawOrigin")
381
+ .title("Draw the origin (0,0).")
382
+ .onChange(function () {
383
+ _self.redraw();
384
+ })
385
+ .listen();
386
+ fold0
387
+ .add(pb.config, "rasterGrid")
388
+ .title("Draw a fine raster instead a full grid.")
389
+ .onChange(function () {
390
+ _self.redraw();
391
+ })
392
+ .listen();
393
+ fold0
394
+ .add(pb.config, "drawRaster")
395
+ .title("If set to false no raster or grid will be drawn at all.")
396
+ .onChange(function () {
397
+ _self.redraw();
398
+ })
399
+ .listen();
400
+ fold0.add(pb.config, "redrawOnResize").title("Automatically redraw the data if window or canvas is resized.").listen();
401
+ fold0
402
+ .addColor(pb.config, "backgroundColor")
403
+ .onChange(function () {
404
+ _self.redraw();
405
+ })
406
+ .title("Choose a background color.");
407
+ fold0.add(dummy, "resetOffset").title("Reset the draw offset to (0,0).");
408
+ fold0.add(dummy, "resetScale").title("Reset the draw scale to (1.,1.).");
409
+
410
+ if (pb.config.enableSVGExport) {
411
+ var foldExport = gui.addFolder("Export");
412
+ foldExport.close(); // important only for lil-gui
413
+ foldExport.add(pb.config, "saveFile").name("SVG Image").title("Save as SVG.");
414
+ globalThis.utils.guiFolders["editor_settings.export"] = foldExport;
213
415
  }
214
- };
215
- _addDrawConfigElement(fold0100, "", pb.drawConfig);
216
416
 
217
- fold0
218
- .add(pb.config, "scaleX")
219
- .title("Scale x.")
220
- .min(0.01)
221
- .max(10.0)
222
- .step(0.01)
223
- .onChange(function () {
224
- _self.draw.scale.x = _self.fill.scale.x = _self.config.scaleX;
225
- _self.redraw();
226
- })
227
- .listen();
228
- fold0
229
- .add(pb.config, "scaleY")
230
- .title("Scale y.")
231
- .min(0.01)
232
- .max(10.0)
233
- .step(0.01)
234
- .onChange(function () {
235
- _self.draw.scale.y = _self.fill.scale.y = _self.config.scaleY;
236
- _self.redraw();
237
- })
238
- .listen();
239
- fold0
240
- .add(pb.config, "offsetX")
241
- .title("Offset x.")
242
- .step(10.0)
243
- .onChange(function () {
244
- _self.draw.offset.x = _self.fill.offset.x = _self.config.offsetX;
245
- _self.redraw();
246
- })
247
- .listen();
248
- fold0
249
- .add(pb.config, "offsetY")
250
- .title("Offset y.")
251
- .step(10.0)
252
- .onChange(function () {
253
- _self.draw.offset.y = _self.fill.offset.y = _self.config.offsetY;
254
- _self.redraw();
255
- })
256
- .listen();
257
- fold0
258
- .add(pb.config, "drawOrigin")
259
- .title("Draw the origin (0,0).")
260
- .onChange(function () {
261
- _self.redraw();
262
- })
263
- .listen();
264
- fold0
265
- .add(pb.config, "rasterGrid")
266
- .title("Draw a fine raster instead a full grid.")
267
- .onChange(function () {
268
- _self.redraw();
269
- })
270
- .listen();
271
- fold0
272
- .add(pb.config, "drawRaster")
273
- .title("If set to false no raster or grid will be drawn at all.")
274
- .onChange(function () {
275
- _self.redraw();
276
- })
277
- .listen();
278
- fold0.add(pb.config, "redrawOnResize").title("Automatically redraw the data if window or canvas is resized.").listen();
279
- fold0
280
- .addColor(pb.config, "backgroundColor")
281
- .onChange(function () {
282
- _self.redraw();
283
- })
284
- .title("Choose a background color.");
285
- fold0.add(dummy, "resetOffset").title("Reset the draw offset to (0,0).");
286
- fold0.add(dummy, "resetScale").title("Reset the draw scale to (1.,1.).");
417
+ if (typeof CSSBackdropEffects !== "undefined") {
418
+ try {
419
+ var backdropEffects = new CSSBackdropEffects(pb, gui, _tryGetFilterGETParams());
420
+ // CSSBackdropEffects.DEFAULT_FILTER_VALUES);
421
+ globalThis.utils["cssBackdropEffects"] = backdropEffects;
422
+ } catch (e) {
423
+ console.warn("[creategui] Failed to create backdrop effect input for gui.", e);
424
+ }
425
+ }
287
426
 
288
- if (pb.config.enableSVGExport) {
289
- var foldExport = gui.addFolder("Export");
290
- foldExport.add(pb.config, "saveFile").name("SVG Image").title("Save as SVG.");
291
- globalThis.utils.guiFolders["editor_settings.export"] = foldExport;
292
- }
427
+ globalThis.utils.guiFolders["editor_settings"] = fold0;
428
+ globalThis.utils.guiFolders["draw_settings"] = fold01;
293
429
 
294
- globalThis.utils.guiFolders["editor_settings"] = fold0;
295
- globalThis.utils.guiFolders["draw_settings"] = fold01;
430
+ return gui;
431
+ };
296
432
 
297
- return gui;
298
- }; // END creategui
433
+ return createGuiFun;
434
+ })(); // END creategui