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
@@ -19,6 +19,7 @@
19
19
  * @modified 2022-11-23 Added `drawRaster` to the `Config` interface.
20
20
  * @modified 2023-02-10 All non-function attributes of the `Config` interface are now mandatory.
21
21
  * @modified 2023-09-29 Added the `randomPoint(...)` function declaration to the IBounds interface.
22
+ * @modified 2024-08-25 Added the `CSSBackdropFilterParams` params to the global params (all optional).
22
23
  **/
23
24
  import { Vertex } from "../Vertex";
24
25
  import { Vector } from "../Vector";
@@ -34,6 +35,7 @@ import { Line } from "../Line";
34
35
  import { PlotBoilerplate } from "../PlotBoilerplate";
35
36
  import { DrawLib } from "./DrawLib";
36
37
  import { PBText } from "../PBText";
38
+ import { CSSBackdropFilterParams } from "./externals";
37
39
  /**
38
40
  * @classdesc Coordinates (x,y) on the plane.
39
41
  *
@@ -93,7 +95,7 @@ export interface CanvasWrapper {
93
95
  /**
94
96
  * The config that's used by PB.
95
97
  */
96
- export interface Config extends Record<string, boolean | number | string | Function | HTMLCanvasElement | SVGElement | undefined> {
98
+ export interface Config extends Record<string, boolean | number | string | Function | HTMLCanvasElement | SVGElement | undefined>, Pick<CSSBackdropFilterParams, "isBackdropFiltersEnabled"> {
97
99
  canvas: HTMLCanvasElement | SVGElement | string;
98
100
  fullSize: boolean;
99
101
  fitToParent: boolean;
@@ -137,7 +139,7 @@ export interface Config extends Record<string, boolean | number | string | Funct
137
139
  /**
138
140
  * For initialization the constructor needs a mix of config and draw-settings.
139
141
  */
140
- export interface PBParams extends Config {
142
+ export interface PBParams extends Config, CSSBackdropFilterParams {
141
143
  title?: string;
142
144
  }
143
145
  export interface DrawSettings {
@@ -19,6 +19,7 @@
19
19
  * @modified 2022-11-23 Added `drawRaster` to the `Config` interface.
20
20
  * @modified 2023-02-10 All non-function attributes of the `Config` interface are now mandatory.
21
21
  * @modified 2023-09-29 Added the `randomPoint(...)` function declaration to the IBounds interface.
22
+ * @modified 2024-08-25 Added the `CSSBackdropFilterParams` params to the global params (all optional).
22
23
  **/
23
24
  export {};
24
25
  //# sourceMappingURL=core.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../ts/interfaces/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;IAqBI"}
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../ts/interfaces/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;IAsBI"}
@@ -12,3 +12,45 @@ export interface DatGuiProps {
12
12
  closed?: boolean;
13
13
  closeOnTop?: boolean;
14
14
  }
15
+ export interface GUI {
16
+ domElement: HTMLElement;
17
+ }
18
+ export interface LilGuiProps {
19
+ name?: string;
20
+ load?: object;
21
+ parent?: dat.GUI;
22
+ autoPlace?: boolean;
23
+ hideable?: boolean;
24
+ closed?: boolean;
25
+ closeOnTop?: boolean;
26
+ }
27
+ /**
28
+ * This is just for the backdrop-filter vaules (CSS after effects filters). They are not directly
29
+ * used by PB but can be passed through by the config/params.
30
+ */
31
+ export interface CSSBackdropFilterParams {
32
+ isBackdropFiltersEnabled?: boolean;
33
+ effectFilterColor?: string;
34
+ isEffectsColorEnabled?: boolean;
35
+ opacity?: number;
36
+ isOpacityEnabled?: boolean;
37
+ invert?: number;
38
+ isInvertEnabled?: boolean;
39
+ sepia?: number;
40
+ isSepiaEnabled?: boolean;
41
+ blur?: number;
42
+ isBlurEnabled?: boolean;
43
+ brightness?: number;
44
+ isBrightnessEnabled?: boolean;
45
+ contrast?: number;
46
+ isContrastEnabled?: boolean;
47
+ dropShadow?: number;
48
+ dropShadowColor?: string;
49
+ isDropShadowEnabled?: boolean;
50
+ grayscale?: number;
51
+ isGrayscaleEnabled?: boolean;
52
+ hueRotate?: number;
53
+ isHueRotateEnabled?: boolean;
54
+ saturate?: number;
55
+ isSaturateEnabled?: boolean;
56
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Approach to observe objects from other scripts to be initialized.
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2024-07-08
6
+ * @version 1.0.0
7
+ */
8
+ export declare class InitializationObserver<T, E> {
9
+ private _acceptRejectPairs;
10
+ private _timeoutMessage;
11
+ private _initializedValue;
12
+ private _isInitialized;
13
+ constructor(timeout: number, timeoutMessage?: E);
14
+ accept(value: T): void;
15
+ private _fireAccept;
16
+ private _fireReject;
17
+ waitForInitialized(): Promise<T>;
18
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Approach to observe objects from other scripts to be initialized.
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2024-07-08
6
+ * @version 1.0.0
7
+ */
8
+ export class InitializationObserver {
9
+ constructor(timeout, timeoutMessage) {
10
+ this._acceptRejectPairs = [];
11
+ this._timeoutMessage = timeoutMessage !== null && timeoutMessage !== void 0 ? timeoutMessage : null;
12
+ globalThis.setTimeout(() => {
13
+ var _a;
14
+ if (this._isInitialized) {
15
+ return; // NOOP
16
+ }
17
+ // else
18
+ if (!this._timeoutMessage) {
19
+ console.warn("Failed to initialize object. Reason unknown.");
20
+ }
21
+ this._fireReject((_a = this._timeoutMessage) !== null && _a !== void 0 ? _a : null);
22
+ }, timeout);
23
+ }
24
+ accept(value) {
25
+ if (this._isInitialized) {
26
+ return;
27
+ }
28
+ this._isInitialized = true;
29
+ this._initializedValue = value;
30
+ this._fireAccept(value);
31
+ }
32
+ _fireAccept(value) {
33
+ this._acceptRejectPairs.forEach(pair => {
34
+ pair.accept(value);
35
+ });
36
+ }
37
+ _fireReject(error) {
38
+ this._acceptRejectPairs.forEach(pair => {
39
+ pair.reject(error);
40
+ });
41
+ }
42
+ waitForInitialized() {
43
+ const _self = this;
44
+ // If the value is already present, then accept immediately
45
+ if (_self._isInitialized) {
46
+ return new Promise((accept, reject) => {
47
+ accept(_self._initializedValue);
48
+ });
49
+ }
50
+ else {
51
+ return new Promise((accept, reject) => {
52
+ _self._acceptRejectPairs.push({ accept, reject });
53
+ });
54
+ }
55
+ }
56
+ }
57
+ //# sourceMappingURL=InitializationObserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitializationObserver.js","sourceRoot":"","sources":["../../ts/utils/InitializationObserver.ts"],"names":[],"mappings":"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,KAAK,CAAC,cAAc,EAAE,CAAC;YACzB,OAAO,IAAI,OAAO,CAAI,CAAC,MAA0B,EAAE,MAAiC,EAAE,EAAE;gBACtF,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YAClC,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,OAAO,CAAI,CAAC,MAA0B,EAAE,MAAiC,EAAE,EAAE;gBACtF,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
@@ -2,13 +2,15 @@
2
2
  * Wraps a Record<string,string> and adds type conversion methods (developed this in
3
3
  * some other project) and added this here (2023-10-28).
4
4
  *
5
- * @author Ikars Kappler
6
- * @version 1.0.0
7
- * @date 2023-03-13
5
+ * @author Ikars Kappler
6
+ * @version 1.0.0
7
+ * @date 2023-03-13
8
+ * @modified 2024-08-26 Added the `hasParam` method.
8
9
  */
9
10
  export declare class Params {
10
11
  baseParams: Record<string, string>;
11
12
  constructor(baseParams: Record<string, string>);
13
+ hasParam(name: string): boolean;
12
14
  getString(name: string, fallback: string): string;
13
15
  getNumber(name: string, fallback: number): number;
14
16
  getBoolean(name: string, fallback: boolean): boolean;
@@ -2,14 +2,18 @@
2
2
  * Wraps a Record<string,string> and adds type conversion methods (developed this in
3
3
  * some other project) and added this here (2023-10-28).
4
4
  *
5
- * @author Ikars Kappler
6
- * @version 1.0.0
7
- * @date 2023-03-13
5
+ * @author Ikars Kappler
6
+ * @version 1.0.0
7
+ * @date 2023-03-13
8
+ * @modified 2024-08-26 Added the `hasParam` method.
8
9
  */
9
10
  export class Params {
10
11
  constructor(baseParams) {
11
12
  this.baseParams = baseParams;
12
13
  }
14
+ hasParam(name) {
15
+ return this.baseParams.hasOwnProperty(name);
16
+ }
13
17
  getString(name, fallback) {
14
18
  let value = this.baseParams[name];
15
19
  if (typeof value === "undefined" || !value || (value = value.trim()).length === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"Params.js","sourceRoot":"","sources":["../../ts/utils/Params.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,OAAO,MAAM;IAGjB,YAAY,UAAkC;QAC5C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,QAAgB;QACtC,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClF,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,QAAgB;QACtC,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClF,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,UAAU,CAAC,IAAY,EAAE,QAAiB;QACxC,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClF,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,KAAK,GAAG,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAClC,IA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,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClF,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,UAAU,CAAC,IAAY,EAAE,QAAiB;QACxC,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClF,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,KAAK,GAAG,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAClC,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC;YAC7G,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;YACnH,OAAO,KAAK,CAAC;QACf,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @requires lil-gui
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2021-12-13
6
+ * @modified 2022-01-10
7
+ * @modified 2024-06-25 Ported to typescript and moved to utils/dom (was located inside demos before).
8
+ * @version 1.1.0
9
+ */
10
+ import { GUI } from "../../interfaces/externals";
11
+ interface ITogglerConfig {
12
+ guiDoubleSize?: boolean;
13
+ }
14
+ export declare const guiSizeToggler: (gui: GUI, config: ITogglerConfig, cssProps: Record<string, string>) => {
15
+ update: () => void;
16
+ };
17
+ export {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @requires lil-gui
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2021-12-13
6
+ * @modified 2022-01-10
7
+ * @modified 2024-06-25 Ported to typescript and moved to utils/dom (was located inside demos before).
8
+ * @version 1.1.0
9
+ */
10
+ /**
11
+ * @param {GUI} gui - The GUI (compatible with dat.gui and lil-gui).
12
+ * @param {boolean} guiDoubleSize - True or false.
13
+ * @param {Record<string,string>} cssProps - The CSS props to use.
14
+ */
15
+ const applyGuiSize = (gui, guiDoubleSize, cssProps) => {
16
+ if (cssProps && cssProps.hasOwnProperty("transformOrigin")) {
17
+ gui.domElement.style["transform-origin"] = cssProps["transformOrigin"];
18
+ }
19
+ else {
20
+ gui.domElement.style["transform-origin"] = "100% 0%";
21
+ }
22
+ const transform = cssProps && cssProps.hasOwnProperty("transform") ? cssProps["transform"] + " " : "";
23
+ console.log("transform", transform);
24
+ if (guiDoubleSize) {
25
+ gui.domElement.style["transform"] = transform + "scale(2.0)";
26
+ }
27
+ else {
28
+ gui.domElement.style["transform"] = transform + "scale(1.0)";
29
+ }
30
+ };
31
+ export const guiSizeToggler /* gst */ = (gui, config, cssProps) => {
32
+ return {
33
+ update: function () {
34
+ applyGuiSize(gui, Boolean(config.guiDoubleSize), cssProps);
35
+ }
36
+ };
37
+ };
38
+ //# sourceMappingURL=guiSizeToggler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guiSizeToggler.js","sourceRoot":"","sources":["../../../ts/utils/dom/guiSizeToggler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,GAAQ,EAAE,aAAsB,EAAE,QAAgC,EAAE,EAAE;IAC1F,IAAI,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC3D,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACzE,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;IACvD,CAAC;IAED,MAAM,SAAS,GAAG,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACpC,IAAI,aAAa,EAAE,CAAC;QAClB,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,YAAY,CAAC;IAC/D,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,YAAY,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,CAAC,SAAS,GAAG,CAAC,GAAQ,EAAE,MAAsB,EAAE,QAAgC,EAAE,EAAE;IAC7G,OAAO;QACL,MAAM,EAAE;YACN,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC7D,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -9,5 +9,6 @@
9
9
  * Ported to typescript.
10
10
  * @date 2021-05-21
11
11
  * @modified 2024-03-10 Fixed some type for Typescript 5 compatibility.
12
+ * @modified 2024-08-26 Decoding URI components in GET params.
12
13
  */
13
14
  export declare const gup: () => Record<string, string>;
@@ -9,6 +9,7 @@
9
9
  * Ported to typescript.
10
10
  * @date 2021-05-21
11
11
  * @modified 2024-03-10 Fixed some type for Typescript 5 compatibility.
12
+ * @modified 2024-08-26 Decoding URI components in GET params.
12
13
  */
13
14
  // Get the URI GET params as an assoc.
14
15
  //
@@ -18,7 +19,8 @@
18
19
  export const gup = () => {
19
20
  const vars = {};
20
21
  globalThis.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, (_m, key, value) => {
21
- return (vars[key] = value);
22
+ const keyName = key;
23
+ return (vars[decodeURIComponent(keyName)] = value);
22
24
  });
23
25
  return vars;
24
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"gup.js","sourceRoot":"","sources":["../../ts/utils/gup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,sCAAsC;AACtC,EAAE;AACF,6BAA6B;AAC7B,WAAW;AACX,sKAAsK;AACtK,MAAM,CAAC,MAAM,GAAG,GAAG,GAA2B,EAAE;IAC9C,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,EAAU,EAAE,GAAW,EAAE,KAAa,EAAU,EAAE;QAC7G,OAAO,CAAC,IAAI,CAAC,GAAmB,CAAC,GAAG,KAAK,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
1
+ {"version":3,"file":"gup.js","sourceRoot":"","sources":["../../ts/utils/gup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,sCAAsC;AACtC,EAAE;AACF,6BAA6B;AAC7B,WAAW;AACX,sKAAsK;AACtK,MAAM,CAAC,MAAM,GAAG,GAAG,GAA2B,EAAE;IAC9C,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,EAAU,EAAE,GAAW,EAAE,KAAa,EAAU,EAAE;QAC7G,MAAM,OAAO,GAAW,GAAmB,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
package/src/index-gl.js CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
  // Fetch the GET params
17
17
  let GUP = gup();
18
+ var isDarkmode = detectDarkMode(GUP);
19
+ var isDarkmode = detectDarkMode(GUP);
18
20
 
19
21
  window.addEventListener("load", function () {
20
22
  // All config params are optional.
@@ -40,7 +42,7 @@
40
42
  autoAdjustOffset: true,
41
43
  offsetAdjustXPercent: 50,
42
44
  offsetAdjustYPercent: 50,
43
- backgroundColor: "#ffffff",
45
+ backgroundColor: isDarkmode ? "#000000" : "#ffffff",
44
46
  enableMouse: true,
45
47
  enableTouch: true,
46
48
  enableKeys: true,
package/src/index.js CHANGED
@@ -23,6 +23,7 @@
23
23
  window.pbInitialized = true;
24
24
  // Fetch the GET params
25
25
  let GUP = gup();
26
+ var isDarkmode = detectDarkMode(GUP);
26
27
  var isInitialized = false;
27
28
 
28
29
  // All config params are optional.
@@ -49,7 +50,7 @@
49
50
  offsetAdjustXPercent: 50,
50
51
  offsetAdjustYPercent: 50,
51
52
  autoDetectRetina: false,
52
- backgroundColor: "#ffffff",
53
+ backgroundColor: isDarkmode ? "#000000" : "#ffffff",
53
54
  enableMouse: true,
54
55
  enableTouch: true,
55
56
  enableKeys: true,
@@ -83,7 +83,10 @@
83
83
  * @modified 2023-02-10 Cleaning up most type errors in the main class (mostly null checks).
84
84
  * @modified 2023-02-10 Adding `enableZoom` and `enablePan` (both default true) to have the option to disable these functions.
85
85
  * @modified 2023-09-29 Adding proper dicionary key and value types to the params of `PlotBoilerplate.utils.safeMergeByKeys` (was `object` before).
86
- * @version 1.17.3
86
+ * @modified 2024-07-08 Adding `PlotBoilerplate.getGUI()` to retrieve the GUI instance.
87
+ * @modified 2024-08-25 Extending main class `PlotBoilerplate` optional param `isBackdropFiltersEnabled`.
88
+ *
89
+ * @version 1.19.0
87
90
  *
88
91
  * @file PlotBoilerplate
89
92
  * @fileoverview The main class.
@@ -126,7 +129,8 @@ import {
126
129
  SVGPathParams,
127
130
  XYCoords,
128
131
  XYDimension,
129
- DatGuiProps
132
+ DatGuiProps, // DEPRECATED. Please do not use any more.
133
+ LilGuiProps
130
134
  } from "./interfaces";
131
135
  import { PBText } from "./PBText";
132
136
  import { AlloyFingerOptions } from "alloyfinger-typescript/src/cjs/alloy_finger";
@@ -326,6 +330,11 @@ export class PlotBoilerplate {
326
330
  */
327
331
  private renderTime: number = 0;
328
332
 
333
+ /**
334
+ * A storage variable for retrieving the GUI instance once it was created.
335
+ */
336
+ private _gui: GUI | null = null;
337
+
329
338
  /**
330
339
  * The constructor.
331
340
  *
@@ -461,7 +470,9 @@ export class PlotBoilerplate {
461
470
  enablePan: f.bool(config, "enablePan", true), // default=true
462
471
 
463
472
  // Experimental (and unfinished)
464
- enableGL: f.bool(config, "enableGL", false)
473
+ enableGL: f.bool(config, "enableGL", false),
474
+
475
+ isBackdropFiltersEnabled: f.bool(config, "isBackdropFiltersEnabled", true)
465
476
  }; // END confog
466
477
 
467
478
  /**
@@ -706,7 +717,10 @@ export class PlotBoilerplate {
706
717
  if (typeof globalThis["saveAs" as keyof Object] !== "function") {
707
718
  throw "Cannot save file; did you load the ./utils/savefile helper function and the eligrey/SaveFile library?";
708
719
  }
709
- var _saveAs : (blob:Blob, filename:string) => void = globalThis["saveAs" as keyof Object] as (blob:Blob, filename:string) => void;
720
+ var _saveAs: (blob: Blob, filename: string) => void = globalThis["saveAs" as keyof Object] as (
721
+ blob: Blob,
722
+ filename: string
723
+ ) => void;
710
724
  _saveAs(blob, "plotboilerplate.svg");
711
725
  }
712
726
 
@@ -2024,7 +2038,10 @@ export class PlotBoilerplate {
2024
2038
  };
2025
2039
 
2026
2040
  // Make PB work together with both, AlloyFinger as a esm module or a commonjs function.
2027
- if (typeof globalThis["AlloyFinger" as keyof Object] === "function" || typeof globalThis["createAlloyFinger" as keyof Object] === "function") {
2041
+ if (
2042
+ typeof globalThis["AlloyFinger" as keyof Object] === "function" ||
2043
+ typeof globalThis["createAlloyFinger" as keyof Object] === "function"
2044
+ ) {
2028
2045
  try {
2029
2046
  var touchMovePos: Vertex | undefined | null = null;
2030
2047
  var touchDownPos: Vertex | undefined | null = null;
@@ -2162,7 +2179,10 @@ export class PlotBoilerplate {
2162
2179
  } as unknown as AlloyFingerOptions; // END afProps
2163
2180
  if (window["createAlloyFinger" as keyof Object]) {
2164
2181
  // window["createAlloyFinger"](this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
2165
- const createAlloyFinger = window["createAlloyFinger" as keyof Object] as (elem:HTMLElement|SVGElement, afProps:AlloyFingerOptions ) => void;
2182
+ const createAlloyFinger = window["createAlloyFinger" as keyof Object] as (
2183
+ elem: HTMLElement | SVGElement,
2184
+ afProps: AlloyFingerOptions
2185
+ ) => void;
2166
2186
  createAlloyFinger(this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
2167
2187
  } else {
2168
2188
  /* tslint:disable-next-line */
@@ -2214,19 +2234,30 @@ export class PlotBoilerplate {
2214
2234
  * @memberof PlotBoilerplate
2215
2235
  * @return {dat.gui.GUI}
2216
2236
  **/
2217
- createGUI(props?: DatGuiProps): GUI {
2237
+ createGUI(props?: DatGuiProps | LilGuiProps): GUI {
2218
2238
  // This function moved to the helper utils.
2219
2239
  // We do not want to include the whole dat.GUI package.
2220
- const utils: {createGUI? : (pb:PlotBoilerplate,props:DatGuiProps|undefined)=>GUI } | undefined = globalThis["utils" as keyof Object] as any as {createGUI? : (pb:PlotBoilerplate,props:DatGuiProps|undefined)=>GUI } | undefined;
2240
+ const utils: { createGUI?: (pb: PlotBoilerplate, props: DatGuiProps | undefined) => GUI } | undefined = globalThis[
2241
+ "utils" as keyof Object
2242
+ ] as any as { createGUI?: (pb: PlotBoilerplate, props: DatGuiProps | undefined) => GUI } | undefined;
2221
2243
  // if (globalThis["utils"] && typeof globalThis["utils"].createGUI == "function") {
2222
2244
  // return (globalThis["utils" as keyof Object] as any as ({createGUI : (pb:PlotBoilerplate,props:DatGuiProps|undefined)=>GUI })).createGUI(this, props);
2223
2245
  if (utils && typeof utils.createGUI === "function") {
2224
- return utils.createGUI(this, props);
2225
- } else {
2226
- throw "Cannot create dat.GUI instance; did you load the ./utils/creategui helper function an the dat.GUI library?";
2246
+ return (this._gui = utils.createGUI(this, props));
2247
+ } else {
2248
+ throw "Cannot create dat.GUI or lil-gui instance; did you load the ./utils/creategui helper function an the dat.GUI/lil-gui library?";
2227
2249
  }
2228
2250
  }
2229
2251
 
2252
+ /**
2253
+ * Retriebe the GUI once it was created. If the `createGUI` method was not called or failed to create any
2254
+ * GUI then null is returned.
2255
+ * @returns {GUI | null}
2256
+ */
2257
+ getGUI(): GUI | null {
2258
+ return this._gui;
2259
+ }
2260
+
2230
2261
  /**
2231
2262
  * A set of helper functions.
2232
2263
  **/
@@ -46,7 +46,8 @@
46
46
  * @modified 2023-10-04 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
47
47
  * @modified 2024-01-30 Fixing an issue with immutable style sets; changes to the global draw config did not reflect here (do now).
48
48
  * @modified 2024-03-10 Fixing some types for Typescript 5 compatibility.
49
- * @version 1.6.9
49
+ * @modified 2024-07-24 Caching custom style defs in a private buffer variable.
50
+ * @version 1.6.10
50
51
  **/
51
52
 
52
53
  import { CircleSector } from "./CircleSector";
@@ -202,6 +203,11 @@ export class drawutilssvg implements DrawLib<void | SVGElement> {
202
203
  */
203
204
  private drawConfig: DrawConfig;
204
205
 
206
+ /**
207
+ * A buffer element for custom style defs (will be re-generated on each draw cycle).
208
+ */
209
+ private customStyleDefs: Map<string, string>;
210
+
205
211
  /**
206
212
  * Passed from primary to secondary instance.
207
213
  */
@@ -312,6 +318,15 @@ export class drawutilssvg implements DrawLib<void | SVGElement> {
312
318
  console.warn(`Warning: your draw config is missing the key '${k}' which is required.`);
313
319
  }
314
320
  }
321
+
322
+ if (this.customStyleDefs) {
323
+ rules.push("\n/* Custom styles */\n");
324
+ this.customStyleDefs.forEach((value: string, key: string) => {
325
+ rules.push(key + " { " + value + " }");
326
+ });
327
+ // this.nodeStyle.innerHTML += "\n/* Custom styles */\n" + rules.join("\n");
328
+ }
329
+
315
330
  this.nodeStyle.innerHTML = rules.join("\n");
316
331
  }
317
332
 
@@ -337,11 +352,7 @@ export class drawutilssvg implements DrawLib<void | SVGElement> {
337
352
  * @param {Map<string,string>} defs
338
353
  */
339
354
  addCustomStyleDefs(defs: Map<string, string>) {
340
- const buffer: string[] = [];
341
- defs.forEach((value: string, key: string) => {
342
- buffer.push(key + " { " + value + " }");
343
- });
344
- this.nodeStyle.innerHTML += "\n/* Custom styles */\n" + buffer.join("\n");
355
+ this.customStyleDefs = defs;
345
356
  }
346
357
 
347
358
  /**
@@ -19,6 +19,7 @@
19
19
  * @modified 2022-11-23 Added `drawRaster` to the `Config` interface.
20
20
  * @modified 2023-02-10 All non-function attributes of the `Config` interface are now mandatory.
21
21
  * @modified 2023-09-29 Added the `randomPoint(...)` function declaration to the IBounds interface.
22
+ * @modified 2024-08-25 Added the `CSSBackdropFilterParams` params to the global params (all optional).
22
23
  **/
23
24
 
24
25
  import { Vertex } from "../Vertex";
@@ -35,6 +36,7 @@ import { Line } from "../Line";
35
36
  import { PlotBoilerplate } from "../PlotBoilerplate";
36
37
  import { DrawLib } from "./DrawLib";
37
38
  import { PBText } from "../PBText";
39
+ import { CSSBackdropFilterParams } from "./externals";
38
40
 
39
41
  /**
40
42
  * @classdesc Coordinates (x,y) on the plane.
@@ -113,7 +115,8 @@ export interface CanvasWrapper {
113
115
  * The config that's used by PB.
114
116
  */
115
117
  export interface Config
116
- extends Record<string, boolean | number | string | Function | HTMLCanvasElement | SVGElement | undefined> {
118
+ extends Record<string, boolean | number | string | Function | HTMLCanvasElement | SVGElement | undefined>,
119
+ Pick<CSSBackdropFilterParams, "isBackdropFiltersEnabled"> {
117
120
  canvas: HTMLCanvasElement | SVGElement | string; // Your canvas element in the DOM (required).
118
121
  fullSize: boolean; // If set to true the canvas will gain full window size.
119
122
  fitToParent: boolean; // If set to true the canvas will gain the size of its parent container (overrides fullSize).
@@ -174,7 +177,7 @@ export interface Config
174
177
  /**
175
178
  * For initialization the constructor needs a mix of config and draw-settings.
176
179
  */
177
- export interface PBParams extends Config {
180
+ export interface PBParams extends Config, CSSBackdropFilterParams {
178
181
  title?: string; // Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
179
182
  // No more additional attributes, just merge two interfaces.
180
183
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  // https://www.npmjs.com/package/@types/dat.gui
8
+ // @DEPRECATED Dat.GUI is replaced by lil-gui.
8
9
  export interface DatGuiProps {
9
10
  name?: string;
10
11
  load?: object;
@@ -14,3 +15,52 @@ export interface DatGuiProps {
14
15
  closed?: boolean;
15
16
  closeOnTop?: boolean;
16
17
  }
18
+
19
+ // Compatible with dat.gui and lil-gui.
20
+ export interface GUI {
21
+ domElement: HTMLElement;
22
+ }
23
+
24
+ export interface LilGuiProps {
25
+ name?: string;
26
+ load?: object;
27
+ parent?: dat.GUI;
28
+ autoPlace?: boolean;
29
+ hideable?: boolean;
30
+ closed?: boolean;
31
+ closeOnTop?: boolean;
32
+ }
33
+
34
+ /**
35
+ * This is just for the backdrop-filter vaules (CSS after effects filters). They are not directly
36
+ * used by PB but can be passed through by the config/params.
37
+ */
38
+ export interface CSSBackdropFilterParams {
39
+ // A global switch to enable/disable all filters
40
+ isBackdropFiltersEnabled?: boolean;
41
+ // This is just for the global effect color
42
+ effectFilterColor?: string; // "#204a87",
43
+ isEffectsColorEnabled?: boolean;
44
+ // These are real filter values
45
+ opacity?: number; // 0.5,
46
+ isOpacityEnabled?: boolean; // false,
47
+ invert?: number; // 0.8,
48
+ isInvertEnabled?: boolean; // false,
49
+ sepia?: number; // 0.9,
50
+ isSepiaEnabled?: boolean; // false,
51
+ blur?: number; // 2, // px
52
+ isBlurEnabled?: boolean; // false,
53
+ brightness?: number; // 0.6,
54
+ isBrightnessEnabled?: boolean; // false,
55
+ contrast?: number; // 0.9,
56
+ isContrastEnabled?: boolean; // false,
57
+ dropShadow?: number; // 4, // px
58
+ dropShadowColor?: string; // "#00ffff",
59
+ isDropShadowEnabled?: boolean; // false,
60
+ grayscale?: number; // 0.3,
61
+ isGrayscaleEnabled?: boolean; // false,
62
+ hueRotate?: number; // 120, // deg
63
+ isHueRotateEnabled?: boolean; // false,
64
+ saturate?: number; // 2.0,
65
+ isSaturateEnabled?: boolean; // false
66
+ }