From a63081d5b021d5cdb84a9a9b5ff59708d60c674d Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Sat, 16 Nov 2024 13:35:35 -0500 Subject: [PATCH 1/2] feat: migrate https://github.com/upsetjs/bubblesets-js/commit/c477ac979920024a25cbdc7cbcf84a878628eb5a --- src/routing.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routing.ts b/src/routing.ts index e7474bd..624c553 100644 --- a/src/routing.ts +++ b/src/routing.ts @@ -316,7 +316,7 @@ function rerouteLine( } // else through top to bottom, calculate areas const totalArea = item.height * item.width; - const leftArea = item.height * ((topIntersect.x - item.x + (rightIntersect.x - item.x)) * 0.5); + const leftArea = item.height * ((topIntersect.x - item.x + (bottomIntersect.x - item.x)) * 0.5); if (leftArea < totalArea * 0.5) { // go around left if (topIntersect.x > bottomIntersect.x) @@ -368,7 +368,7 @@ function rerouteLine( } // else through top to bottom, calculate areas const totalArea = item.height * item.width; - const leftArea = item.height * ((topIntersect.x - item.x + (rightIntersect.x - item.x)) * 0.5); + const leftArea = item.height * ((topIntersect.x - item.x + (bottomIntersect.x - item.x)) * 0.5); if (leftArea < totalArea * 0.5) { // go around right if (topIntersect.x > bottomIntersect.x) From dc3fe4982c766fa6dc8a3d64f04da3ec4a80a4d4 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Sat, 16 Nov 2024 13:54:29 -0500 Subject: [PATCH 2/2] docs: add docu about options migrated from https://github.com/upsetjs/bubblesets-js/commit/a66ea717ad2a3ccb24d9e046377e8661f65aa07d --- src/BubbleSets.ts | 48 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/src/BubbleSets.ts b/src/BubbleSets.ts index eafe4ff..47d6859 100644 --- a/src/BubbleSets.ts +++ b/src/BubbleSets.ts @@ -11,32 +11,55 @@ import { PointPath } from './PointPath'; export interface IPotentialOptions { /** - * how many pixels per potential area group to improve speed + * the resolution of the algorithm in square pixels * @default 4 */ pixelGroup?: number; + /** + * the amount of space to move the virtual edge when wrapping around obstacles + * @default 10 + */ morphBuffer?: number; } export interface IRoutingOptions { virtualEdges?: boolean; /** - * maximum number of iterations when computing routes between members + * number of times to run the algorithm to refine the path finding in difficult areas * @default 100 */ maxRoutingIterations?: number; + /** + * the amount of space to move the virtual edge when wrapping around obstacles + * @default 10 + */ morphBuffer?: number; } export interface IOutlineOptions { /** - * maximum number of iterations when computing the contour + * number of times to refine the boundary * @default 20 */ maxMarchingIterations?: number; - + /** + * the distance from edges at which energy is 1 (full influence) + * @default 10 + */ edgeR0?: number; + /** + * the distance from edges at which energy is 0 (no influence) + * @default 20 + */ edgeR1?: number; + /** + * the distance from nodes which energy is 1 (full influence) + * @default 15 + */ nodeR0?: number; + /** + * the distance from nodes at which energy is 0 (no influence) + * @default 50 + */ nodeR1?: number; threshold?: number; @@ -48,14 +71,15 @@ export interface IOutlineOptions { export interface IBubbleSetOptions extends IRoutingOptions, IOutlineOptions, IPotentialOptions {} export const defaultOptions: Readonly> = { - maxRoutingIterations: 100, - maxMarchingIterations: 20, - pixelGroup: 4, - edgeR0: 10, - edgeR1: 20, - nodeR0: 15, - nodeR1: 50, - morphBuffer: 10, + // override these defaults to change the spacing and bubble precision; affects performance and appearance + maxRoutingIterations: 100, // number of times to run the algorithm to refine the path finding in difficult areas + maxMarchingIterations: 20, // number of times to refine the boundary + pixelGroup: 4, // the resolution of the algorithm in square pixels + edgeR0: 10, // the distance from edges at which energy is 1 (full influence) + edgeR1: 20, // the distance from edges at which energy is 0 (no influence) + nodeR0: 15, // the distance from nodes which energy is 1 (full influence) + nodeR1: 50, // the distance from nodes at which energy is 0 (no influence) + morphBuffer: 10, // the amount of space to move the virtual edge when wrapping around obstacles threshold: 1, memberInfluenceFactor: 1,