fix: address review feedback for Range editor

This commit is contained in:
Terry Jia
2026-04-08 21:17:52 -04:00
parent b95636fc81
commit 2019704fc3
8 changed files with 68 additions and 133 deletions

View File

@@ -1,4 +1,23 @@
import type { ReadOnlyRect } from '@/lib/litegraph/src/interfaces'
/**
* Linearly maps a value from [min, max] to [0, 1].
* Returns 0 when min equals max to avoid division by zero.
*/
export function normalize(value: number, min: number, max: number): number {
return max === min ? 0 : (value - min) / (max - min)
}
/**
* Linearly maps a normalized value from [0, 1] back to [min, max].
*/
export function denormalize(
normalized: number,
min: number,
max: number
): number {
return min + normalized * (max - min)
}
import type { Bounds } from '@/renderer/core/layout/types'
/** Simple 2D point or size as [x, y] or [width, height] */