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.
- package/README.md +17 -1
- package/dist/index.esm.js +101 -50
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/plotboilerplate.browser.min.js +1 -1
- package/dist/plotboilerplate.browser.min.js.map +1 -1
- package/dist/plotboilerplate.js +102 -50
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +2 -1
- package/src/cjs/BezierPath.js +2 -3
- package/src/cjs/BezierPath.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +7 -1
- package/src/cjs/PlotBoilerplate.js +76 -33
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Triangle.js +1 -0
- package/src/cjs/Triangle.js.map +1 -1
- package/src/cjs/draw.d.ts +6 -5
- package/src/cjs/draw.js +4 -3
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.d.ts +7 -6
- package/src/cjs/drawgl.js +5 -4
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +8 -6
- package/src/cjs/drawutilssvg.js +14 -7
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +4 -3
- package/src/cjs/interfaces/DrawLib.js +1 -0
- package/src/cjs/interfaces/DrawLib.js.map +1 -1
- package/src/cjs/interfaces/core.d.ts +33 -30
- package/src/cjs/interfaces/core.js +1 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/utils/datastructures/Color.d.ts +3 -1
- package/src/cjs/utils/datastructures/Color.js +12 -1
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- package/src/cjs/utils/module.js +4 -2
- package/src/esm/BezierPath.js +2 -3
- package/src/esm/BezierPath.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +7 -1
- package/src/esm/PlotBoilerplate.js +75 -33
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Triangle.js +1 -0
- package/src/esm/Triangle.js.map +1 -1
- package/src/esm/draw.d.ts +6 -5
- package/src/esm/draw.js +4 -3
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.d.ts +7 -6
- package/src/esm/drawgl.js +5 -4
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +8 -6
- package/src/esm/drawutilssvg.js +14 -7
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +4 -3
- package/src/esm/interfaces/DrawLib.js +1 -0
- package/src/esm/interfaces/DrawLib.js.map +1 -1
- package/src/esm/interfaces/core.d.ts +33 -30
- package/src/esm/interfaces/core.js +1 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/utils/datastructures/Color.d.ts +3 -1
- package/src/esm/utils/datastructures/Color.js +12 -1
- package/src/esm/utils/datastructures/Color.js.map +1 -1
- package/src/ts/BezierPath.ts +2 -3
- package/src/ts/PlotBoilerplate.ts +75 -32
- package/src/ts/Triangle.ts +2 -1
- package/src/ts/draw.ts +6 -5
- package/src/ts/drawgl.ts +9 -8
- package/src/ts/drawutilssvg.ts +23 -16
- package/src/ts/interfaces/DrawLib.ts +4 -3
- package/src/ts/interfaces/core.ts +33 -30
- 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
|
|
106
|
-
fitToParent
|
|
107
|
-
scaleX
|
|
108
|
-
scaleY
|
|
109
|
-
offsetX
|
|
110
|
-
offsetY
|
|
111
|
-
rasterGrid
|
|
112
|
-
drawRaster
|
|
113
|
-
rasterScaleX
|
|
114
|
-
rasterScaleY
|
|
115
|
-
rasterAdjustFactor
|
|
116
|
-
drawOrigin
|
|
117
|
-
autoAdjustOffset
|
|
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
|
|
121
|
+
offsetAdjustXPercent: number; // The x-fallback position for the origin after
|
|
121
122
|
// resizing the canvas.
|
|
122
|
-
offsetAdjustYPercent
|
|
123
|
+
offsetAdjustYPercent: number; // The y-fallback position for the origin after
|
|
123
124
|
// resizing the canvas.
|
|
124
|
-
defaultCanvasWidth
|
|
125
|
+
defaultCanvasWidth: number; // The canvas size fallback (width) if no automatic resizing
|
|
125
126
|
// is switched on.
|
|
126
|
-
defaultCanvasHeight
|
|
127
|
+
defaultCanvasHeight: number; // The canvas size fallback (height) if no automatic resizing
|
|
127
128
|
// is switched on.
|
|
128
|
-
canvasWidthFactor
|
|
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
|
|
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
|
|
135
|
-
cssScaleY
|
|
136
|
-
cssUniformScale
|
|
137
|
-
backgroundColor
|
|
138
|
-
redrawOnResize
|
|
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
|
|
147
|
-
enableTouch
|
|
148
|
-
enableKeys
|
|
149
|
-
enableMouseWheel
|
|
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
|
|
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
|
|
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
|
-
* @
|
|
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;
|