diff --git a/src/apply/index.ts b/src/apply/index.ts index 67e6cc1..5829f85 100644 --- a/src/apply/index.ts +++ b/src/apply/index.ts @@ -1,7 +1,5 @@ -#!/usr/bin/env zx - import type { ImageAnalysisData } from "../analyze/analysis.ts" -import { cacheDir, chalkDebug, configDir, loadConfig, map, mapEaseOutQuint, mapEaseOutSqrt } from "../utils.ts" +import { cacheDir, chalkDebug, configDir, loadConfig, map, mapEaseOutExp, mapEaseOutQuint } from "../utils.ts" import { type ApplicationConfig, defaultConfig, findMatchingImages, getOpenMeteoData } from "./application.ts" import * as SunCalc from "suncalc" import "zx/globals" @@ -57,8 +55,9 @@ const chromaValue = map( config.chromaRange.end, ) -const lightnessValue = mapEaseOutSqrt( +const lightnessValue = mapEaseOutExp( Number(openMeteoData.shortwaveRadiation), + 1 / 4, 0, 1000, config.lightnessRange.start, diff --git a/src/utils.ts b/src/utils.ts index 8cb46d6..c11135c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -89,10 +89,10 @@ export function mapEaseOutQuint(number: number, min: number, max: number, newMin return easeOutQuint((number - min) / (max - min)) * (newMax - newMin) + newMin } -function easeOutSqrt(x: number): number { - return Math.sqrt(x) +function easeOutExp(x: number, exp: number): number { + return Math.pow(x, exp); } -export function mapEaseOutSqrt(number: number, min: number, max: number, newMin: number, newMax: number) { - return easeOutSqrt((number - min) / (max - min)) * (newMax - newMin) + newMin +export function mapEaseOutExp(number: number, exp: number, min: number, max: number, newMin: number, newMax: number) { + return easeOutExp((number - min) / (max - min), exp) * (newMax - newMin) + newMin } \ No newline at end of file