plotboilerplate 1.20.1 → 1.20.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 (70) hide show
  1. package/README.md +17 -1
  2. package/dist/index.esm.js +101 -50
  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 +102 -50
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +2 -1
  11. package/src/cjs/BezierPath.js +2 -3
  12. package/src/cjs/BezierPath.js.map +1 -1
  13. package/src/cjs/PlotBoilerplate.d.ts +7 -1
  14. package/src/cjs/PlotBoilerplate.js +76 -33
  15. package/src/cjs/PlotBoilerplate.js.map +1 -1
  16. package/src/cjs/Triangle.js +1 -0
  17. package/src/cjs/Triangle.js.map +1 -1
  18. package/src/cjs/draw.d.ts +6 -5
  19. package/src/cjs/draw.js +4 -3
  20. package/src/cjs/draw.js.map +1 -1
  21. package/src/cjs/drawgl.d.ts +7 -6
  22. package/src/cjs/drawgl.js +5 -4
  23. package/src/cjs/drawgl.js.map +1 -1
  24. package/src/cjs/drawutilssvg.d.ts +8 -6
  25. package/src/cjs/drawutilssvg.js +14 -7
  26. package/src/cjs/drawutilssvg.js.map +1 -1
  27. package/src/cjs/interfaces/DrawLib.d.ts +4 -3
  28. package/src/cjs/interfaces/DrawLib.js +1 -0
  29. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  30. package/src/cjs/interfaces/core.d.ts +33 -30
  31. package/src/cjs/interfaces/core.js +1 -0
  32. package/src/cjs/interfaces/core.js.map +1 -1
  33. package/src/cjs/utils/datastructures/Color.d.ts +3 -1
  34. package/src/cjs/utils/datastructures/Color.js +12 -1
  35. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  36. package/src/cjs/utils/module.js +4 -2
  37. package/src/esm/BezierPath.js +2 -3
  38. package/src/esm/BezierPath.js.map +1 -1
  39. package/src/esm/PlotBoilerplate.d.ts +7 -1
  40. package/src/esm/PlotBoilerplate.js +75 -33
  41. package/src/esm/PlotBoilerplate.js.map +1 -1
  42. package/src/esm/Triangle.js +1 -0
  43. package/src/esm/Triangle.js.map +1 -1
  44. package/src/esm/draw.d.ts +6 -5
  45. package/src/esm/draw.js +4 -3
  46. package/src/esm/draw.js.map +1 -1
  47. package/src/esm/drawgl.d.ts +7 -6
  48. package/src/esm/drawgl.js +5 -4
  49. package/src/esm/drawgl.js.map +1 -1
  50. package/src/esm/drawutilssvg.d.ts +8 -6
  51. package/src/esm/drawutilssvg.js +14 -7
  52. package/src/esm/drawutilssvg.js.map +1 -1
  53. package/src/esm/interfaces/DrawLib.d.ts +4 -3
  54. package/src/esm/interfaces/DrawLib.js +1 -0
  55. package/src/esm/interfaces/DrawLib.js.map +1 -1
  56. package/src/esm/interfaces/core.d.ts +33 -30
  57. package/src/esm/interfaces/core.js +1 -0
  58. package/src/esm/interfaces/core.js.map +1 -1
  59. package/src/esm/utils/datastructures/Color.d.ts +3 -1
  60. package/src/esm/utils/datastructures/Color.js +12 -1
  61. package/src/esm/utils/datastructures/Color.js.map +1 -1
  62. package/src/ts/BezierPath.ts +2 -3
  63. package/src/ts/PlotBoilerplate.ts +75 -32
  64. package/src/ts/Triangle.ts +2 -1
  65. package/src/ts/draw.ts +6 -5
  66. package/src/ts/drawgl.ts +9 -8
  67. package/src/ts/drawutilssvg.ts +23 -16
  68. package/src/ts/interfaces/DrawLib.ts +4 -3
  69. package/src/ts/interfaces/core.ts +33 -30
  70. package/src/ts/utils/datastructures/Color.ts +13 -1
@@ -17,6 +17,7 @@
17
17
  * @modified 2022-08-01 Added `title` param to the `PBParams` interface.
18
18
  * @modified 2022-10-25 Added `origin` param to the `DrawConfig` interface.
19
19
  * @modified 2022-11-23 Added `drawRaster` to the `Config` interface.
20
+ * @modified 2023-02-10 All non-function attributes of the `Config` interface are now mandatory.
20
21
  **/
21
22
 
22
23
  import { Vertex } from "../Vertex";
@@ -102,40 +103,40 @@ export interface CanvasWrapper {
102
103
  */
103
104
  export interface Config {
104
105
  canvas: HTMLCanvasElement | string; // Your canvas element in the DOM (required).
105
- fullSize?: boolean; // If set to true the canvas will gain full window size.
106
- fitToParent?: boolean; // If set to true the canvas will gain the size of its parent container (overrides fullSize).
107
- scaleX?: number; // The initial x-zoom. Default is 1.0.
108
- scaleY?: number; // The initial y-zoom. Default is 1.0.
109
- offsetX?: number; // The initial x-offset. Default is 0.0. Note that autoAdjustOffset=true overrides these values.
110
- offsetY?: number; // The initial y-offset. Default is 0.0. Note that autoAdjustOffset=true overrides these values.
111
- rasterGrid?: boolean; // If set to true the background grid will be drawn rastered.
112
- drawRaster?: boolean; // If set to false, no raster or grid will be drawn at all.
113
- rasterScaleX?: number; // Define the default horizontal raster scale (default=1.0).
114
- rasterScaleY?: number; // Define the default vertical raster scale (default=1.0).
115
- rasterAdjustFactor?: number; // The exponential limit for wrapping down the grid. (2.0 means: halve the grid each 2.0*n zoom step).
116
- drawOrigin?: boolean; // Draw a crosshair at (0,0).
117
- autoAdjustOffset?: boolean; // When set to true then the origin of the XY plane will
106
+ fullSize: boolean; // If set to true the canvas will gain full window size.
107
+ fitToParent: boolean; // If set to true the canvas will gain the size of its parent container (overrides fullSize).
108
+ scaleX: number; // The initial x-zoom. Default is 1.0.
109
+ scaleY: number; // The initial y-zoom. Default is 1.0.
110
+ offsetX: number; // The initial x-offset. Default is 0.0. Note that autoAdjustOffset=true overrides these values.
111
+ offsetY: number; // The initial y-offset. Default is 0.0. Note that autoAdjustOffset=true overrides these values.
112
+ rasterGrid: boolean; // If set to true the background grid will be drawn rastered.
113
+ drawRaster: boolean; // If set to false, no raster or grid will be drawn at all.
114
+ rasterScaleX: number; // Define the default horizontal raster scale (default=1.0).
115
+ rasterScaleY: number; // Define the default vertical raster scale (default=1.0).
116
+ rasterAdjustFactor: number; // The exponential limit for wrapping down the grid. (2.0 means: halve the grid each 2.0*n zoom step).
117
+ drawOrigin: boolean; // Draw a crosshair at (0,0).
118
+ autoAdjustOffset: boolean; // When set to true then the origin of the XY plane will
118
119
  // be re-adjusted automatically (see the params
119
120
  // offsetAdjust{X,Y}Percent for more).
120
- offsetAdjustXPercent?: number; // The x-fallback position for the origin after
121
+ offsetAdjustXPercent: number; // The x-fallback position for the origin after
121
122
  // resizing the canvas.
122
- offsetAdjustYPercent?: number; // The y-fallback position for the origin after
123
+ offsetAdjustYPercent: number; // The y-fallback position for the origin after
123
124
  // resizing the canvas.
124
- defaultCanvasWidth?: number; // The canvas size fallback (width) if no automatic resizing
125
+ defaultCanvasWidth: number; // The canvas size fallback (width) if no automatic resizing
125
126
  // is switched on.
126
- defaultCanvasHeight?: number; // The canvas size fallback (height) if no automatic resizing
127
+ defaultCanvasHeight: number; // The canvas size fallback (height) if no automatic resizing
127
128
  // is switched on.
128
- canvasWidthFactor?: number; // Scaling factor (width) upon the canvas size.
129
+ canvasWidthFactor: number; // Scaling factor (width) upon the canvas size.
129
130
  // In combination with cssScale{X,Y} this can be used to obtain
130
131
  // sub pixel resolutions for retina displays.
131
- canvasHeightFactor?: number; // Scaling factor (height) upon the canvas size.
132
+ canvasHeightFactor: number; // Scaling factor (height) upon the canvas size.
132
133
  // In combination with cssScale{X,Y} this can be used to obtain
133
134
  // sub pixel resolutions for retina displays.
134
- cssScaleX?: number; // Visually resize the canvas (horizontally) using CSS transforms (scale).
135
- cssScaleY?: number; // Visually resize the canvas (vertically) using CSS transforms (scale).
136
- cssUniformScale?: boolean; // CSS scale x and y obtaining aspect ratio.
137
- backgroundColor?: string; // The backround color.
138
- redrawOnResize?: boolean; // Switch auto-redrawing on resize on/off (some applications
135
+ cssScaleX: number; // Visually resize the canvas (horizontally) using CSS transforms (scale).
136
+ cssScaleY: number; // Visually resize the canvas (vertically) using CSS transforms (scale).
137
+ cssUniformScale: boolean; // CSS scale x and y obtaining aspect ratio.
138
+ backgroundColor: string; // The backround color.
139
+ redrawOnResize: boolean; // Switch auto-redrawing on resize on/off (some applications
139
140
  // might want to prevent automatic redrawing to avoid data loss from the draw buffer).
140
141
  preClear?: () => void; // A callback function that will be triggered just before the
141
142
  // draw function clears the canvas (before anything else was drawn).
@@ -143,17 +144,19 @@ export interface Config {
143
144
  // function starts.
144
145
  postDraw?: (draw: DrawLib<any>, fill: DrawLib<any>) => void; // A callback function that will be triggered right after the drawing
145
146
  // process finished.
146
- enableMouse?: boolean; // Indicates if the application should handle mouse events for you.
147
- enableTouch?: boolean; // Indicates if the application should handle touch events for you.
148
- enableKeys?: boolean; // Indicates if the application should handle key events for you.
149
- enableMouseWheel?: boolean; // Indicates if the application should handle mouse wheel events for you.
147
+ enableMouse: boolean; // Indicates if the application should handle mouse events for you.
148
+ enableTouch: boolean; // Indicates if the application should handle touch events for you.
149
+ enableKeys: boolean; // Indicates if the application should handle key events for you.
150
+ enableMouseWheel: boolean; // Indicates if the application should handle mouse wheel events for you.
151
+ enableZoom: boolean; // default=true
152
+ enablePan: boolean; // default=true
150
153
  enableGL?: boolean; // Indicates if the application should use the experimental WebGL features (not recommended).
151
- enableSVGExport?: boolean; // Indicates if the SVG export should be enabled (default is true).
154
+ enableSVGExport: boolean; // Indicates if the SVG export should be enabled (default is true).
152
155
  // Note that changes from the postDraw hook might not be visible in the export.
153
156
  saveFile?: () => void; // When called the save-file dialog will be triggered.
154
157
  setToRetina?: () => void; // When called the resolution will be set to retina.
155
158
 
156
- autoDetectRetina?: boolean; // When set to true (default) the canvas will try to use the display's pixel ratio.
159
+ autoDetectRetina: boolean; // When set to true (default) the canvas will try to use the display's pixel ratio.
157
160
  }
158
161
 
159
162
  /**
@@ -16,7 +16,8 @@
16
16
  * @modified 2021-11-07 Added setRed, setGreen, setBlue, setHue, setSaturation, setLiminance functions.
17
17
  * @modified 2022-05-11 Modified the `clone` function by just copying the numeric calues, not re-calculating the whole color.
18
18
  * @modified 2022-05-11 Fixed the `interpolate` function.
19
- * @version 0.0.11
19
+ * @modified 2023-01-23 Added `Color.set(Color)` function to set all values (r,g,b,h,s,l,a) simultanoeusly.
20
+ * @version 0.0.12
20
21
  **/
21
22
 
22
23
  /**
@@ -155,6 +156,17 @@ export class Color {
155
156
  return this.b;
156
157
  }
157
158
 
159
+ set(color: Color): Color {
160
+ this.r = color.r;
161
+ this.g = color.g;
162
+ this.b = color.b;
163
+ this.a = color.a;
164
+ this.h = color.h;
165
+ this.s = color.s;
166
+ this.l = color.l;
167
+ return this;
168
+ }
169
+
158
170
  setRed(r: number) {
159
171
  this.r = r;
160
172
  return this;