mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 02:01:22 +01:00
refactor(es modules): modulize utils
This commit is contained in:
parent
7ccebec048
commit
21fc303320
20 changed files with 25 additions and 6 deletions
|
|
@ -3,6 +3,7 @@ import {last} from "/src/utils/arrayUtils";
|
|||
import {getSegmentId} from "@/utils/lineUtils";
|
||||
import {rn} from "/src/utils/numberUtils";
|
||||
import {round, parseTransform} from "@/utils/stringUtils";
|
||||
import {si} from "@/utils/unitUtils";
|
||||
|
||||
export class Rulers {
|
||||
constructor() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {dragLegendBox} from "../modules/legend";
|
||||
import {findCell, findGridCell} from "../utils/graphUtils";
|
||||
import {tip, showMainTip} from "./tooltips";
|
||||
import {si, convertTemperature} from "@/utils/unitUtils";
|
||||
|
||||
export function restoreDefaultEvents() {
|
||||
Zoom.setZoomBehavior();
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ const temperatureConversionMap = {
|
|||
"°Rø": temp => rn((temp * 21) / 40 + 7.5) + "°Rø"
|
||||
};
|
||||
|
||||
function convertTemperature(temp) {
|
||||
export function convertTemperature(temp) {
|
||||
const scale = temperatureScale.value || "°C";
|
||||
return temperatureConversionMap[scale](temp);
|
||||
}
|
||||
|
||||
// corvent number to short string with SI postfix
|
||||
function si(n) {
|
||||
// corvert number to short string with SI postfix
|
||||
export function si(n) {
|
||||
if (n >= 1e9) return rn(n / 1e9, 1) + "B";
|
||||
if (n >= 1e8) return rn(n / 1e6) + "M";
|
||||
if (n >= 1e6) return rn(n / 1e6, 1) + "M";
|
||||
|
|
@ -27,8 +27,8 @@ function si(n) {
|
|||
return rn(n);
|
||||
}
|
||||
|
||||
// getInteger number from user input data
|
||||
function getInteger(value) {
|
||||
// convert SI number to integer
|
||||
export function siToInteger(value) {
|
||||
const metric = value.slice(-1);
|
||||
if (metric === "K") return parseInt(value.slice(0, -1) * 1e3);
|
||||
if (metric === "M") return parseInt(value.slice(0, -1) * 1e6);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue