mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-04 17:41:23 +01:00
fix: rename feature path functions and update global declarations
This commit is contained in:
parent
844fc15891
commit
6fc218d635
2 changed files with 8 additions and 4 deletions
|
|
@ -9,6 +9,7 @@ declare global {
|
||||||
tolerance: number,
|
tolerance: number,
|
||||||
highestQuality?: boolean,
|
highestQuality?: boolean,
|
||||||
) => [number, number][];
|
) => [number, number][];
|
||||||
|
var getFeaturePath: (feature: PackedGraphFeature) => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FeaturesHtml {
|
interface FeaturesHtml {
|
||||||
|
|
@ -34,7 +35,7 @@ const featuresRenderer = (): void => {
|
||||||
if (!feature || feature.type === "ocean") continue;
|
if (!feature || feature.type === "ocean") continue;
|
||||||
|
|
||||||
html.paths.push(
|
html.paths.push(
|
||||||
`<path d="${getFeaturePath(feature)}" id="feature_${feature.i}" data-f="${feature.i}"></path>`,
|
`<path d="${featurePathRenderer(feature)}" id="feature_${feature.i}" data-f="${feature.i}"></path>`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (feature.type === "lake") {
|
if (feature.type === "lake") {
|
||||||
|
|
@ -81,7 +82,7 @@ const featuresRenderer = (): void => {
|
||||||
TIME && console.timeEnd("drawFeatures");
|
TIME && console.timeEnd("drawFeatures");
|
||||||
};
|
};
|
||||||
|
|
||||||
function getFeaturePath(feature: PackedGraphFeature): string {
|
function featurePathRenderer(feature: PackedGraphFeature): string {
|
||||||
const points: [number, number][] = feature.vertices.map(
|
const points: [number, number][] = feature.vertices.map(
|
||||||
(vertex: number) => pack.vertices.p[vertex],
|
(vertex: number) => pack.vertices.p[vertex],
|
||||||
);
|
);
|
||||||
|
|
@ -100,3 +101,4 @@ function getFeaturePath(feature: PackedGraphFeature): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.drawFeatures = featuresRenderer;
|
window.drawFeatures = featuresRenderer;
|
||||||
|
window.getFeaturePath = featurePathRenderer;
|
||||||
|
|
@ -17,6 +17,7 @@ interface Marker {
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var drawMarkers: () => void;
|
var drawMarkers: () => void;
|
||||||
|
var drawMarker: (marker: Marker, rescale?: number) => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type PinShapeFunction = (fill: string, stroke: string) => string;
|
type PinShapeFunction = (fill: string, stroke: string) => string;
|
||||||
|
|
@ -56,7 +57,7 @@ const getPin = (shape = "bubble", fill = "#fff", stroke = "#000"): string => {
|
||||||
return shapeFunction(fill, stroke);
|
return shapeFunction(fill, stroke);
|
||||||
};
|
};
|
||||||
|
|
||||||
function drawMarker(marker: Marker, rescale = 1): string {
|
function markerRenderer(marker: Marker, rescale = 1): string {
|
||||||
const {
|
const {
|
||||||
i,
|
i,
|
||||||
icon,
|
icon,
|
||||||
|
|
@ -94,10 +95,11 @@ const markersRenderer = (): void => {
|
||||||
const markersData: Marker[] = pinned
|
const markersData: Marker[] = pinned
|
||||||
? pack.markers.filter((m: Marker) => m.pinned)
|
? pack.markers.filter((m: Marker) => m.pinned)
|
||||||
: pack.markers;
|
: pack.markers;
|
||||||
const html = markersData.map((marker) => drawMarker(marker, rescale));
|
const html = markersData.map((marker) => markerRenderer(marker, rescale));
|
||||||
markers.html(html.join(""));
|
markers.html(html.join(""));
|
||||||
|
|
||||||
TIME && console.timeEnd("drawMarkers");
|
TIME && console.timeEnd("drawMarkers");
|
||||||
};
|
};
|
||||||
|
|
||||||
window.drawMarkers = markersRenderer;
|
window.drawMarkers = markersRenderer;
|
||||||
|
window.drawMarker = markerRenderer;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue