plotboilerplate 1.12.8 → 1.14.0
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 +4 -1
- package/changelog.md +26 -0
- package/dist/index.esm.js +292 -51
- 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 +306 -50
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/BezierPath.d.ts +12 -1
- package/src/cjs/BezierPath.js +34 -5
- package/src/cjs/BezierPath.js.map +1 -1
- package/src/cjs/PBText.d.ts +116 -0
- package/src/cjs/PBText.js +66 -0
- package/src/cjs/PBText.js.map +1 -0
- package/src/cjs/PlotBoilerplate.d.ts +2 -1
- package/src/cjs/PlotBoilerplate.js +41 -14
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Vertex.d.ts +18 -4
- package/src/cjs/Vertex.js +24 -7
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/draw.d.ts +30 -2
- package/src/cjs/draw.js +51 -6
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.d.ts +29 -2
- package/src/cjs/drawgl.js +21 -4
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +25 -7
- package/src/cjs/drawutilssvg.js +62 -14
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/entry.js +1 -0
- package/src/cjs/index.d.ts +1 -0
- package/src/cjs/index.js +1 -0
- package/src/cjs/index.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +27 -6
- package/src/cjs/interfaces/DrawLib.js +3 -0
- package/src/cjs/interfaces/DrawLib.js.map +1 -1
- package/src/cjs/interfaces/core.d.ts +9 -1
- 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 +28 -15
- package/src/cjs/utils/datastructures/Color.js +276 -88
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- package/src/esm/BezierPath.d.ts +12 -1
- package/src/esm/BezierPath.js +34 -5
- package/src/esm/BezierPath.js.map +1 -1
- package/src/esm/PBText.d.ts +116 -0
- package/src/esm/PBText.js +61 -0
- package/src/esm/PBText.js.map +1 -0
- package/src/esm/PlotBoilerplate.d.ts +2 -1
- package/src/esm/PlotBoilerplate.js +41 -14
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Vertex.d.ts +18 -4
- package/src/esm/Vertex.js +24 -7
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/draw.d.ts +30 -2
- package/src/esm/draw.js +51 -6
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.d.ts +29 -2
- package/src/esm/drawgl.js +21 -4
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +25 -7
- package/src/esm/drawutilssvg.js +62 -14
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/entry.js +1 -0
- package/src/esm/index.d.ts +1 -0
- package/src/esm/index.js +1 -0
- package/src/esm/index.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +27 -6
- package/src/esm/interfaces/DrawLib.js +3 -0
- package/src/esm/interfaces/DrawLib.js.map +1 -1
- package/src/esm/interfaces/core.d.ts +9 -1
- 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 +28 -15
- package/src/esm/utils/datastructures/Color.js +277 -89
- package/src/esm/utils/datastructures/Color.js.map +1 -1
- package/src/ts/BezierPath.ts +37 -5
- package/src/ts/PBText.ts +147 -0
- package/src/ts/PlotBoilerplate.ts +44 -18
- package/src/ts/Vertex.ts +26 -7
- package/src/ts/draw.ts +71 -8
- package/src/ts/drawgl.ts +48 -8
- package/src/ts/drawutilssvg.ts +94 -17
- package/src/ts/index.ts +1 -0
- package/src/ts/interfaces/DrawLib.ts +30 -4
- package/src/ts/interfaces/core.ts +9 -0
- package/src/ts/utils/datastructures/Color.ts +695 -508
- package/dist/plotboilerplate.browser.min.js.LICENSE.txt +0 -8
- package/src/ts/utils/algorithms/clearPolygonDuplicateVertices.ts~ +0 -5
- package/src/ts/utils/algorithms/findPolygonSelfIntersections.ts~ +0 -45
- package/src/ts/utils/algorithms/splitPolygonToNonIntersecting.ts~ +0 -113
- package/src/ts/utils/algorithms/sutherlandHodgman.ts~ +0 -88
- package/src/ts/utils/datastructures/Color.ts~ +0 -331
- package/src/ts/utils/datastructures/Girih.ts~ +0 -151
- package/src/ts/utils/datastructures/GirihTile.ts~ +0 -419
package/src/cjs/entry.js
CHANGED
|
@@ -18,6 +18,7 @@ globalThis.VEllipse = require("./VEllipse.js").VEllipse;
|
|
|
18
18
|
globalThis.Circle = require("./Circle.js").Circle;
|
|
19
19
|
globalThis.CircleSector = require("./CircleSector.js").CircleSector;
|
|
20
20
|
globalThis.PBImage = require("./PBImage.js").PBImage;
|
|
21
|
+
globalThis.PBText = require("./PBText.js").PBText;
|
|
21
22
|
globalThis.MouseHandler = require("./MouseHandler.js").MouseHandler;
|
|
22
23
|
globalThis.KeyHandler = require("./KeyHandler.js").KeyHandler;
|
|
23
24
|
globalThis.drawutils = require("./draw.js").drawutils;
|
package/src/cjs/index.d.ts
CHANGED
package/src/cjs/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __exportStar(require("./KeyHandler"), exports);
|
|
|
25
25
|
__exportStar(require("./Line"), exports);
|
|
26
26
|
__exportStar(require("./MouseHandler"), exports);
|
|
27
27
|
__exportStar(require("./PBImage"), exports);
|
|
28
|
+
__exportStar(require("./PBText"), exports);
|
|
28
29
|
__exportStar(require("./PlotBoilerplate"), exports);
|
|
29
30
|
__exportStar(require("./Polygon"), exports);
|
|
30
31
|
__exportStar(require("./SVGBuilder"), exports);
|
package/src/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA6B;AAC7B,2CAAyB;AACzB,2CAAyB;AACzB,iDAA+B;AAC/B,qDAAmC;AACnC,yCAAuB;AACvB,2CAAyB;AACzB,iDAA+B;AAC/B,8CAA4B;AAC5B,yCAAuB;AACvB,+CAA6B;AAC7B,+CAA6B;AAC7B,yCAAuB;AACvB,iDAA+B;AAC/B,4CAA0B;AAC1B,oDAAkC;AAClC,4CAA0B;AAC1B,+CAA6B;AAC7B,6CAA2B;AAC3B,iDAA+B;AAC/B,2CAAyB;AACzB,6CAA2B;AAC3B,mDAAiC;AACjC,2CAAyB;AACzB,+CAA6B;AAC7B,oDAAkC;AAClC,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA6B;AAC7B,2CAAyB;AACzB,2CAAyB;AACzB,iDAA+B;AAC/B,qDAAmC;AACnC,yCAAuB;AACvB,2CAAyB;AACzB,iDAA+B;AAC/B,8CAA4B;AAC5B,yCAAuB;AACvB,+CAA6B;AAC7B,+CAA6B;AAC7B,yCAAuB;AACvB,iDAA+B;AAC/B,4CAA0B;AAC1B,2CAAyB;AACzB,oDAAkC;AAClC,4CAA0B;AAC1B,+CAA6B;AAC7B,6CAA2B;AAC3B,iDAA+B;AAC/B,2CAAyB;AACzB,6CAA2B;AAC3B,mDAAiC;AACjC,2CAAyB;AACzB,+CAA6B;AAC7B,oDAAkC;AAClC,8CAA4B"}
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
* @modified 2021-03-30 Added the `endDrawCycle` function to `DrawLib`.
|
|
13
13
|
* @modified 2021-05-31 Added the `drawLib.setConfiguration` function.
|
|
14
14
|
* @modified 2021-05-31 Splitted the large interfaces.ts file into this one and others.
|
|
15
|
+
* @modified 2021-11-12 Added `text()` params fontSize, fontFamily, rotation, textAlign.
|
|
16
|
+
* @modified 2021-11-16 Added `text()` params fontWeight and fontStyle.
|
|
17
|
+
* @modified 2021-11-19 Added the `color` param to the `label(...)` function.
|
|
15
18
|
**/
|
|
16
19
|
import { Polygon } from "../Polygon";
|
|
17
20
|
import { Vertex } from "../Vertex";
|
|
@@ -19,6 +22,18 @@ import { SVGPathParams, UID, XYCoords } from "./core";
|
|
|
19
22
|
export interface DrawLibConfiguration {
|
|
20
23
|
blendMode?: 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'lighter' | 'copy' | 'xor' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity' | null;
|
|
21
24
|
}
|
|
25
|
+
export declare type FontWeight = "normal" | "bold" | "bolder" | "lighter" | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
26
|
+
export declare type FontStyle = "normal" | "italic" | "oblique";
|
|
27
|
+
export interface FontOptions {
|
|
28
|
+
color?: string;
|
|
29
|
+
fontFamily?: string;
|
|
30
|
+
fontSize?: number;
|
|
31
|
+
fontStyle?: FontStyle;
|
|
32
|
+
fontWeight?: FontWeight;
|
|
33
|
+
lineHeight?: number;
|
|
34
|
+
textAlign?: CanvasRenderingContext2D["textAlign"];
|
|
35
|
+
rotation?: number;
|
|
36
|
+
}
|
|
22
37
|
/**
|
|
23
38
|
* An interface all drawing libraries must implement to be used with PlotBoilerplate.
|
|
24
39
|
*
|
|
@@ -389,20 +404,25 @@ export interface DrawLib<R> {
|
|
|
389
404
|
*/
|
|
390
405
|
polyline: (vertices: Array<Vertex>, isOpen: boolean, color: string, lineWidth?: number) => R;
|
|
391
406
|
/**
|
|
392
|
-
* Draw a text
|
|
407
|
+
* Draw a text at the given relative position.
|
|
393
408
|
*
|
|
394
409
|
* @method text
|
|
395
410
|
* @param {string} text - The text to draw.
|
|
396
411
|
* @param {number} x - The x-position to draw the text at.
|
|
397
412
|
* @param {number} y - The y-position to draw the text at.
|
|
398
|
-
* @param {
|
|
413
|
+
* @param {string=} options.color - The Color to use.
|
|
414
|
+
* @param {string=} options.fontFamily - The font family to use.
|
|
415
|
+
* @param {number=} options.fontSize - The font size (in pixels) to use.
|
|
416
|
+
* @param {FontStyle=} options.fontStyle - The font style to use.
|
|
417
|
+
* @param {FontWeight=} options.fontWeight - The font weight to use.
|
|
418
|
+
* @param {number=} options.lineHeight - The line height (in pixels) to use.
|
|
419
|
+
* @param {number=} options.rotation - The (optional) rotation in radians.
|
|
420
|
+
* @param {string=} options.textAlign - The text align to use. According to the specifiactions (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign) valid values are `"left" || "right" || "center" || "start" || "end"`.
|
|
399
421
|
* @return {void}
|
|
400
422
|
* @instance
|
|
401
423
|
* @memberof drawutils
|
|
402
424
|
*/
|
|
403
|
-
text: (text: string, x: number, y: number, options?:
|
|
404
|
-
color?: string;
|
|
405
|
-
}) => R;
|
|
425
|
+
text: (text: string, x: number, y: number, options?: FontOptions) => R;
|
|
406
426
|
/**
|
|
407
427
|
* Draw a non-scaling text label at the given absolute position.
|
|
408
428
|
*
|
|
@@ -411,11 +431,12 @@ export interface DrawLib<R> {
|
|
|
411
431
|
* @param {number} x - The x-position to draw the text at.
|
|
412
432
|
* @param {number} y - The y-position to draw the text at.
|
|
413
433
|
* @param {number=} rotation - The (aoptional) rotation in radians.
|
|
434
|
+
* @param {string="black"} color - The color to use (default is black).
|
|
414
435
|
* @return {void}
|
|
415
436
|
* @instance
|
|
416
437
|
* @memberof drawutils
|
|
417
438
|
*/
|
|
418
|
-
label: (text: string, x: number, y: number, rotation
|
|
439
|
+
label: (text: string, x: number, y: number, rotation?: number, color?: string) => R;
|
|
419
440
|
/**
|
|
420
441
|
* Draw an SVG-like path given by the specified path data.
|
|
421
442
|
*
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
* @modified 2021-03-30 Added the `endDrawCycle` function to `DrawLib`.
|
|
14
14
|
* @modified 2021-05-31 Added the `drawLib.setConfiguration` function.
|
|
15
15
|
* @modified 2021-05-31 Splitted the large interfaces.ts file into this one and others.
|
|
16
|
+
* @modified 2021-11-12 Added `text()` params fontSize, fontFamily, rotation, textAlign.
|
|
17
|
+
* @modified 2021-11-16 Added `text()` params fontWeight and fontStyle.
|
|
18
|
+
* @modified 2021-11-19 Added the `color` param to the `label(...)` function.
|
|
16
19
|
**/
|
|
17
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
21
|
//# sourceMappingURL=DrawLib.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawLib.js","sourceRoot":"","sources":["../../ts/interfaces/DrawLib.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"DrawLib.js","sourceRoot":"","sources":["../../ts/interfaces/DrawLib.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;IAiBI"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* @modified 2021-05-31 Added the `drawLib.setConfiguration` function.
|
|
14
14
|
* @modified 2021-05-31 Splitted the large interfaces.ts file into this one and others.
|
|
15
15
|
* @modified 2021-06-21 Added `IBounds.getCenter()`.
|
|
16
|
+
* @modified 2021-11-16 Added `text` options to the `DrawConfig`.
|
|
16
17
|
**/
|
|
17
18
|
import { Vertex } from "../Vertex";
|
|
18
19
|
import { Vector } from "../Vector";
|
|
@@ -27,6 +28,7 @@ import { BezierPath } from "../BezierPath";
|
|
|
27
28
|
import { Line } from "../Line";
|
|
28
29
|
import { PlotBoilerplate } from "../PlotBoilerplate";
|
|
29
30
|
import { DrawLib } from "./DrawLib";
|
|
31
|
+
import { PBText } from "../PBText";
|
|
30
32
|
/**
|
|
31
33
|
* @classdesc Coordinates (x,y) on the plane.
|
|
32
34
|
*
|
|
@@ -61,7 +63,7 @@ export interface IBounds {
|
|
|
61
63
|
/**
|
|
62
64
|
* The types that can be drawn and thus added to the draw queue.
|
|
63
65
|
*/
|
|
64
|
-
export declare type Drawable = Vertex | Vector | Triangle | Circle | CircleSector | PBImage | VEllipse | VEllipseSector | Polygon | BezierPath | Line;
|
|
66
|
+
export declare type Drawable = Vertex | Vector | Triangle | Circle | CircleSector | PBImage | PBText | VEllipse | VEllipseSector | Polygon | BezierPath | Line;
|
|
65
67
|
/**
|
|
66
68
|
* A unique identifier (UID) to tell drawables apart in a performant manner.
|
|
67
69
|
*/
|
|
@@ -149,6 +151,12 @@ export interface DrawConfig {
|
|
|
149
151
|
line: DrawSettings;
|
|
150
152
|
vector: DrawSettings;
|
|
151
153
|
image: DrawSettings;
|
|
154
|
+
text: {
|
|
155
|
+
color: string;
|
|
156
|
+
lineWidth: number;
|
|
157
|
+
fill?: boolean;
|
|
158
|
+
anchor?: boolean;
|
|
159
|
+
};
|
|
152
160
|
}
|
|
153
161
|
/** This is a fix for the problem, that the constructor's "name" attribute is not
|
|
154
162
|
* visible in ES6:
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* @modified 2021-05-31 Added the `drawLib.setConfiguration` function.
|
|
15
15
|
* @modified 2021-05-31 Splitted the large interfaces.ts file into this one and others.
|
|
16
16
|
* @modified 2021-06-21 Added `IBounds.getCenter()`.
|
|
17
|
+
* @modified 2021-11-16 Added `text` options to the `DrawConfig`.
|
|
17
18
|
**/
|
|
18
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
20
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../ts/interfaces/core.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../ts/interfaces/core.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;IAgBI"}
|
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
* @modified 2020-10-23 Ported to Typescript.
|
|
9
9
|
* @modified 2021-02-08 Fixed a lot of es2015 compatibility issues.
|
|
10
10
|
* @modified 2021-02-08 Added basic tsdoc/jsdoc comments.
|
|
11
|
-
* @
|
|
11
|
+
* @modified 2021-11-05 Fixing the regex to parse rgba-strings.
|
|
12
|
+
* @modified 2021-11-05 Added return value `this` to all modifier functions (for chaining).
|
|
13
|
+
* @modified 2021-11-07 Changed the behavior of `darken` and `lighten`: the passed value is handled relative now which makes values much easier predictable and makes the change feel more 'natural'.
|
|
14
|
+
* @modified 2021-11-07 Did the same with `saturate` and `desaturate`.
|
|
15
|
+
* @modified 2021-11-07 Did the same with the `fadein` and `fadeout` functions.
|
|
16
|
+
* @modified 2021-11-07 Added setRed, setGreen, setBlue, setHue, setSaturation, setLiminance functions.
|
|
17
|
+
* @version 0.0.10
|
|
12
18
|
**/
|
|
13
19
|
/**
|
|
14
20
|
* @classdesc A color class, inspired by neolitec's Javascript class.
|
|
@@ -101,13 +107,13 @@ export declare class Color {
|
|
|
101
107
|
*/
|
|
102
108
|
red(): number;
|
|
103
109
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
* Get the green component of this RGB(A) color. This method just returns the `g` color attribute.
|
|
111
|
+
*
|
|
112
|
+
* @method green
|
|
113
|
+
* @instance
|
|
114
|
+
* @memberof Color
|
|
115
|
+
* @return {number} A value between 0.0 and 1.0.
|
|
116
|
+
*/
|
|
111
117
|
green(): number;
|
|
112
118
|
/**
|
|
113
119
|
* Get the blue component of this RGB(A) color. This method just returns the `b` color attribute.
|
|
@@ -118,6 +124,13 @@ export declare class Color {
|
|
|
118
124
|
* @return {number} A value between 0.0 and 1.0.
|
|
119
125
|
*/
|
|
120
126
|
blue(): number;
|
|
127
|
+
setRed(r: number): this;
|
|
128
|
+
setBlue(b: number): this;
|
|
129
|
+
setAlpha(a: number): this;
|
|
130
|
+
setGreen(g: number): this;
|
|
131
|
+
setHue(h: number): this;
|
|
132
|
+
setSaturation(s: number): this;
|
|
133
|
+
setLuminance(l: number): this;
|
|
121
134
|
/**
|
|
122
135
|
* Get this color as a CSS `hsl` string.
|
|
123
136
|
*
|
|
@@ -181,13 +194,13 @@ export declare class Color {
|
|
|
181
194
|
* @return {number} A value between 0.0 and 1.0.
|
|
182
195
|
*/
|
|
183
196
|
alpha(): number;
|
|
184
|
-
saturate(v: string | number):
|
|
185
|
-
desaturate(v: string | number):
|
|
186
|
-
lighten(v: string | number):
|
|
187
|
-
darken(v: string | number):
|
|
188
|
-
fadein(v: string | number):
|
|
189
|
-
fadeout(v: string | number):
|
|
190
|
-
spin(v: string | number):
|
|
197
|
+
saturate(v: string | number): Color;
|
|
198
|
+
desaturate(v: string | number): Color;
|
|
199
|
+
lighten(v: string | number): Color;
|
|
200
|
+
darken(v: string | number): Color;
|
|
201
|
+
fadein(v: string | number): Color;
|
|
202
|
+
fadeout(v: string | number): Color;
|
|
203
|
+
spin(v: string | number): Color;
|
|
191
204
|
static makeRGB(...args: any[]): Color;
|
|
192
205
|
static makeHSL(...args: Array<number | string>): Color;
|
|
193
206
|
static makeHEX(value: string): Color;
|