mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-05 13:41:59 +00:00
fix: address review feedback for Range editor
This commit is contained in:
@@ -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] */
|
||||
|
||||
Reference in New Issue
Block a user