Skip to content

Commit

Permalink
Improve documentation and remove useless interface SimplifyFn
Browse files Browse the repository at this point in the history
  • Loading branch information
ignlg committed May 26, 2024
1 parent 938386b commit efd61ae
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 38 deletions.
11 changes: 9 additions & 2 deletions dist/simplify-path-js.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ var SimplifyPath = /** @class */ (function () {
function SimplifyPath(properties) {
var _a, _b, _c, _d;
var _this = this;
/** Both algorithms combined for awesome performance */
/**
* Simplify an array of points with an optional tolerance.
* @param points Array of points to simplify.
* @param tolerance Tolerance in squared units.
* @param highestQuality Flag to enable highest quality simplification.
* @returns Simplified array of points.
* @example
* const simplified = simplifyPath.simplify([{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 2, y: 2 }], 1);
*/
this.simplify = function (points, tolerance, highestQuality) {
if (tolerance === void 0) { tolerance = 1; }
if (highestQuality === void 0) { highestQuality = false; }
Expand Down Expand Up @@ -148,7 +156,6 @@ var SimplifyPath = /** @class */ (function () {
d.forEach(function (di, i) { return (vp[i] -= vp[i]); });
return d.reduce(function (acc, di) { return acc + di * di; }, 0);
};
// rest of the code doesn't care about point format
/** Basic distance-based simplification */
SimplifyPath.prototype.simplifyRadialDist = function (points, sqTolerance) {
var prevPoint = points[0];
Expand Down
11 changes: 9 additions & 2 deletions dist/simplify-path-js.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@
function SimplifyPath(properties) {
var _a, _b, _c, _d;
var _this = this;
/** Both algorithms combined for awesome performance */
/**
* Simplify an array of points with an optional tolerance.
* @param points Array of points to simplify.
* @param tolerance Tolerance in squared units.
* @param highestQuality Flag to enable highest quality simplification.
* @returns Simplified array of points.
* @example
* const simplified = simplifyPath.simplify([{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 2, y: 2 }], 1);
*/
this.simplify = function (points, tolerance, highestQuality) {
if (tolerance === void 0) { tolerance = 1; }
if (highestQuality === void 0) { highestQuality = false; }
Expand Down Expand Up @@ -154,7 +162,6 @@
d.forEach(function (di, i) { return (vp[i] -= vp[i]); });
return d.reduce(function (acc, di) { return acc + di * di; }, 0);
};
// rest of the code doesn't care about point format
/** Basic distance-based simplification */
SimplifyPath.prototype.simplifyRadialDist = function (points, sqTolerance) {
var prevPoint = points[0];
Expand Down
15 changes: 10 additions & 5 deletions dist/types/simplify-path.class.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ export type PointXYZ = Point<{
y: number;
z?: number;
}, 'x' | 'y' | 'z'>;
export interface SimplifyFn<T, P extends keyof T> {
(points: Point<T, P>[], tolerance?: number, highestQuality?: boolean): T[];
}
export declare class SimplifyPath<T = PointXYZ, P extends keyof T = any> {
/**
* Properties of the point object as x, y, z, etc.
Expand Down Expand Up @@ -39,6 +36,14 @@ export declare class SimplifyPath<T = PointXYZ, P extends keyof T = any> {
protected simplifyDouglasPeuckerStep(points: Point<T, P>[], first: number, last: number, sqTolerance: number, simplified: Point<T, P>[]): void;
/** Simplification using Ramer-Douglas-Peucker algorithm */
protected simplifyRamerDouglasPeucker(points: Point<T, P>[], sqTolerance: number): Point<T, P>[];
/** Both algorithms combined for awesome performance */
simplify: SimplifyFn<T, P>;
/**
* Simplify an array of points with an optional tolerance.
* @param points Array of points to simplify.
* @param tolerance Tolerance in squared units.
* @param highestQuality Flag to enable highest quality simplification.
* @returns Simplified array of points.
* @example
* const simplified = simplifyPath.simplify([{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 2, y: 2 }], 1);
*/
simplify: (points: Point<T, P>[], tolerance?: number, highestQuality?: boolean) => T[];
}
42 changes: 42 additions & 0 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
@@ -1,22 +1,64 @@
:root {
--light-hl-0: #0000FF;
--dark-hl-0: #569CD6;
--light-hl-1: #000000;
--dark-hl-1: #D4D4D4;
--light-hl-2: #0070C1;
--dark-hl-2: #4FC1FF;
--light-hl-3: #001080;
--dark-hl-3: #9CDCFE;
--light-hl-4: #795E26;
--dark-hl-4: #DCDCAA;
--light-hl-5: #098658;
--dark-hl-5: #B5CEA8;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}

@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--code-background: var(--light-code-background);
} }

@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--code-background: var(--dark-code-background);
} }

:root[data-theme='light'] {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--code-background: var(--light-code-background);
}

:root[data-theme='dark'] {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--code-background: var(--dark-code-background);
}

.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
.hl-3 { color: var(--hl-3); }
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
pre, code { background: var(--code-background); }
2 changes: 1 addition & 1 deletion docs/assets/navigation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/assets/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 21 additions & 15 deletions docs/classes/SimplifyPath.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/interfaces/SimplifyFn.html

This file was deleted.

Loading

0 comments on commit efd61ae

Please sign in to comment.