Skip to content

Commit

Permalink
Merge pull request #13 from HautaniemiLab/configurable-control-points
Browse files Browse the repository at this point in the history
feat: adjustable tentacle control points
  • Loading branch information
tuner authored Jan 2, 2025
2 parents edfcad0 + 39fd745 commit 51de8f0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/gui/gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const DEFAULT_LAYOUT_PROPERTIES = {
columnSpacing: 90,
tentacleWidth: 2,
tentacleSpacing: 5,
inOutCPDistance: 0.3,
bundleCPDistance: 0.6,
sampleFontSize: 12,
showLegend: true,
phylogenyColorScheme: true,
Expand Down Expand Up @@ -86,6 +88,8 @@ export function setupGui(container: HTMLElement, tables: DataTables) {
layoutFolder.add(layoutProps, "columnSpacing", 10, 200);
layoutFolder.add(layoutProps, "tentacleWidth", 0.1, 5);
layoutFolder.add(layoutProps, "tentacleSpacing", 0, 10);
layoutFolder.add(layoutProps, "inOutCPDistance", 0.1, 0.45);
layoutFolder.add(layoutProps, "bundleCPDistance", 0.1, 1.2);
layoutFolder.add(layoutProps, "bellTipShape", 0, 1);
layoutFolder.add(layoutProps, "bellTipSpread", 0, 1);
layoutFolder.add(layoutProps, "bellStrokeWidth", 0, 3);
Expand Down
5 changes: 3 additions & 2 deletions src/jellyfish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ function drawTentacles(
const iMid = inputCoords.y + inputCoords.height / 2;

// The distance as a fraction of column spacing
const inputOutputCPDist = 0.3;
const inputOutputCPDist = layoutProps.inOutCPDistance;
// Position of bezier's control points (input and output)
const ixc = lerp(ox, ix, 1 - inputOutputCPDist);
const oxc = lerp(ox, ix, inputOutputCPDist);
Expand All @@ -726,7 +726,8 @@ function drawTentacles(
// points.
const q = 2;
const scDist =
0.9 / ((slopeMultiplier([ix - ox, iy - oy]) + q) / (1 + q));
layoutProps.bundleCPDistance /
((slopeMultiplier([ixc - oxc, iy - oy]) + q) / (1 + q));

const midXCpOffset = lerp(ix, sx, 1 - scDist * 0.5) - sx;
const midYCpOffset = lerp(iMid, sy, 1 - scDist) - sy;
Expand Down
2 changes: 2 additions & 0 deletions src/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface LayoutProperties extends BellPlotProperties {
columnSpacing: number;
tentacleWidth: number;
tentacleSpacing: number;
inOutCPDistance: number;
bundleCPDistance: number;
sampleFontSize: number;
showLegend: boolean;
phylogenyColorScheme: boolean;
Expand Down

0 comments on commit 51de8f0

Please sign in to comment.