Skip to content

Commit 191707e

Browse files
authored
Merge pull request #15 from upsetjs/release/v3.0.0
Release v3.0.0
2 parents c2366dd + e9fd5df commit 191707e

File tree

4 files changed

+1126
-1081
lines changed

4 files changed

+1126
-1081
lines changed

package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bubblesets-js",
33
"description": "JavaScript implementation of bubble sets by Christopher Collins",
4-
"version": "2.3.4",
4+
"version": "3.0.0",
55
"author": {
66
"name": "Samuel Gratzl",
77
"email": "sam@sgratzl.com",
@@ -25,8 +25,9 @@
2525
"last 2 Chrome versions",
2626
"last 2 Firefox versions"
2727
],
28+
"type": "module",
29+
"main": "build/index.js",
2830
"module": "build/index.js",
29-
"main": "build/index.cjs",
3031
"require": "build/index.cjs",
3132
"umd": "build/index.umd.js",
3233
"unpkg": "build/index.umd.min.js",
@@ -46,31 +47,31 @@
4647
"src/**/*.ts"
4748
],
4849
"devDependencies": {
49-
"@babel/core": "^7.25.8",
50-
"@babel/preset-env": "^7.25.8",
51-
"@eslint/js": "^9.13.0",
50+
"@babel/core": "^7.26.0",
51+
"@babel/preset-env": "^7.26.0",
52+
"@eslint/js": "^9.15.0",
5253
"@rollup/plugin-babel": "^6.0.4",
5354
"@rollup/plugin-commonjs": "^28.0.1",
5455
"@rollup/plugin-node-resolve": "^15.3.0",
5556
"@rollup/plugin-replace": "^6.0.1",
5657
"@rollup/plugin-typescript": "^12.1.1",
57-
"@vitest/coverage-v8": "^2.1.3",
58+
"@vitest/coverage-v8": "^2.1.5",
5859
"@yarnpkg/sdks": "^3.2.0",
59-
"eslint": "^9.13.0",
60+
"eslint": "~9.14.0",
6061
"eslint-plugin-prettier": "^5.2.1",
6162
"jsdom": "^25.0.1",
6263
"prettier": "^3.3.3",
6364
"rimraf": "^6.0.1",
64-
"rollup": "^4.24.0",
65+
"rollup": "^4.27.2",
6566
"rollup-plugin-dts": "^6.1.1",
6667
"rollup-plugin-terser": "^7.0.2",
6768
"ts-jest": "^29.2.5",
68-
"tslib": "^2.8.0",
69-
"typedoc": "^0.26.10",
69+
"tslib": "^2.8.1",
70+
"typedoc": "^0.26.11",
7071
"typescript": "^5.6.3",
71-
"typescript-eslint": "^8.10.0",
72-
"vite": "^5.4.9",
73-
"vitest": "^2.1.3"
72+
"typescript-eslint": "^8.14.0",
73+
"vite": "^5.4.11",
74+
"vitest": "^2.1.5"
7475
},
7576
"scripts": {
7677
"clean": "rimraf --glob build node_modules \"*.tgz\" \"*.tsbuildinfo\"",

src/BubbleSets.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,55 @@ import { PointPath } from './PointPath';
1111

1212
export interface IPotentialOptions {
1313
/**
14-
* how many pixels per potential area group to improve speed
14+
* the resolution of the algorithm in square pixels
1515
* @default 4
1616
*/
1717
pixelGroup?: number;
18+
/**
19+
* the amount of space to move the virtual edge when wrapping around obstacles
20+
* @default 10
21+
*/
1822
morphBuffer?: number;
1923
}
2024

2125
export interface IRoutingOptions {
2226
virtualEdges?: boolean;
2327
/**
24-
* maximum number of iterations when computing routes between members
28+
* number of times to run the algorithm to refine the path finding in difficult areas
2529
* @default 100
2630
*/
2731
maxRoutingIterations?: number;
32+
/**
33+
* the amount of space to move the virtual edge when wrapping around obstacles
34+
* @default 10
35+
*/
2836
morphBuffer?: number;
2937
}
3038
export interface IOutlineOptions {
3139
/**
32-
* maximum number of iterations when computing the contour
40+
* number of times to refine the boundary
3341
* @default 20
3442
*/
3543
maxMarchingIterations?: number;
36-
44+
/**
45+
* the distance from edges at which energy is 1 (full influence)
46+
* @default 10
47+
*/
3748
edgeR0?: number;
49+
/**
50+
* the distance from edges at which energy is 0 (no influence)
51+
* @default 20
52+
*/
3853
edgeR1?: number;
54+
/**
55+
* the distance from nodes which energy is 1 (full influence)
56+
* @default 15
57+
*/
3958
nodeR0?: number;
59+
/**
60+
* the distance from nodes at which energy is 0 (no influence)
61+
* @default 50
62+
*/
4063
nodeR1?: number;
4164

4265
threshold?: number;
@@ -48,14 +71,15 @@ export interface IOutlineOptions {
4871
export interface IBubbleSetOptions extends IRoutingOptions, IOutlineOptions, IPotentialOptions {}
4972

5073
export const defaultOptions: Readonly<Required<IBubbleSetOptions>> = {
51-
maxRoutingIterations: 100,
52-
maxMarchingIterations: 20,
53-
pixelGroup: 4,
54-
edgeR0: 10,
55-
edgeR1: 20,
56-
nodeR0: 15,
57-
nodeR1: 50,
58-
morphBuffer: 10,
74+
// override these defaults to change the spacing and bubble precision; affects performance and appearance
75+
maxRoutingIterations: 100, // number of times to run the algorithm to refine the path finding in difficult areas
76+
maxMarchingIterations: 20, // number of times to refine the boundary
77+
pixelGroup: 4, // the resolution of the algorithm in square pixels
78+
edgeR0: 10, // the distance from edges at which energy is 1 (full influence)
79+
edgeR1: 20, // the distance from edges at which energy is 0 (no influence)
80+
nodeR0: 15, // the distance from nodes which energy is 1 (full influence)
81+
nodeR1: 50, // the distance from nodes at which energy is 0 (no influence)
82+
morphBuffer: 10, // the amount of space to move the virtual edge when wrapping around obstacles
5983

6084
threshold: 1,
6185
memberInfluenceFactor: 1,

src/routing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ function rerouteLine(
316316
}
317317
// else through top to bottom, calculate areas
318318
const totalArea = item.height * item.width;
319-
const leftArea = item.height * ((topIntersect.x - item.x + (rightIntersect.x - item.x)) * 0.5);
319+
const leftArea = item.height * ((topIntersect.x - item.x + (bottomIntersect.x - item.x)) * 0.5);
320320
if (leftArea < totalArea * 0.5) {
321321
// go around left
322322
if (topIntersect.x > bottomIntersect.x)
@@ -368,7 +368,7 @@ function rerouteLine(
368368
}
369369
// else through top to bottom, calculate areas
370370
const totalArea = item.height * item.width;
371-
const leftArea = item.height * ((topIntersect.x - item.x + (rightIntersect.x - item.x)) * 0.5);
371+
const leftArea = item.height * ((topIntersect.x - item.x + (bottomIntersect.x - item.x)) * 0.5);
372372
if (leftArea < totalArea * 0.5) {
373373
// go around right
374374
if (topIntersect.x > bottomIntersect.x)

0 commit comments

Comments
 (0)