Skip to content

Commit 86fc62d

Browse files
fix: rename feature path functions and update global declarations (Azgaar#1303)
* fix: rename feature path functions and update global declarations * chore: lint
1 parent b73557d commit 86fc62d

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/renderers/draw-features.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ declare global {
99
tolerance: number,
1010
highestQuality?: boolean,
1111
) => [number, number][];
12+
var getFeaturePath: (feature: PackedGraphFeature) => string;
1213
}
1314

1415
interface FeaturesHtml {
@@ -34,7 +35,7 @@ const featuresRenderer = (): void => {
3435
if (!feature || feature.type === "ocean") continue;
3536

3637
html.paths.push(
37-
`<path d="${getFeaturePath(feature)}" id="feature_${feature.i}" data-f="${feature.i}"></path>`,
38+
`<path d="${featurePathRenderer(feature)}" id="feature_${feature.i}" data-f="${feature.i}"></path>`,
3839
);
3940

4041
if (feature.type === "lake") {
@@ -81,7 +82,7 @@ const featuresRenderer = (): void => {
8182
TIME && console.timeEnd("drawFeatures");
8283
};
8384

84-
function getFeaturePath(feature: PackedGraphFeature): string {
85+
function featurePathRenderer(feature: PackedGraphFeature): string {
8586
const points: [number, number][] = feature.vertices.map(
8687
(vertex: number) => pack.vertices.p[vertex],
8788
);
@@ -100,3 +101,4 @@ function getFeaturePath(feature: PackedGraphFeature): string {
100101
}
101102

102103
window.drawFeatures = featuresRenderer;
104+
window.getFeaturePath = featurePathRenderer;

src/renderers/draw-markers.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface Marker {
1717

1818
declare global {
1919
var drawMarkers: () => void;
20+
var drawMarker: (marker: Marker, rescale?: number) => string;
2021
}
2122

2223
type PinShapeFunction = (fill: string, stroke: string) => string;
@@ -56,7 +57,7 @@ const getPin = (shape = "bubble", fill = "#fff", stroke = "#000"): string => {
5657
return shapeFunction(fill, stroke);
5758
};
5859

59-
function drawMarker(marker: Marker, rescale = 1): string {
60+
function markerRenderer(marker: Marker, rescale = 1): string {
6061
const {
6162
i,
6263
icon,
@@ -94,10 +95,11 @@ const markersRenderer = (): void => {
9495
const markersData: Marker[] = pinned
9596
? pack.markers.filter((m: Marker) => m.pinned)
9697
: pack.markers;
97-
const html = markersData.map((marker) => drawMarker(marker, rescale));
98+
const html = markersData.map((marker) => markerRenderer(marker, rescale));
9899
markers.html(html.join(""));
99100

100101
TIME && console.timeEnd("drawMarkers");
101102
};
102103

103104
window.drawMarkers = markersRenderer;
105+
window.drawMarker = markerRenderer;

0 commit comments

Comments
 (0)