ratio-lock
Version:
A TypeScript library for managing n numbers with locked ratios. When the ratio is locked, changing one value automatically adjusts all other values to maintain their proportional relationships.
56 lines • 1.47 kB
TypeScript
import type { RatioLockOptions } from './ratio-lock-options.js';
/**
* A class for managing n numbers with locked ratios.
* When the ratio is locked, changing one value automatically adjusts
* all other values to maintain their proportional relationships.
*/
export declare class RatioLock {
private _values;
private _ratios;
private _locked;
private _precision;
/**
* Creates a new RatioLock instance
* @param initialValues - Initial values for the ratio lock
* @param options - Configuration options
*/
constructor(initialValues: number[], options: RatioLockOptions);
private calculateRatios;
private applyPrecision;
/**
* Lock the current ratio
*/
lock(): void;
/**
* Unlock the ratio
*/
unlock(): void;
/**
* Toggle lock state
*/
toggle(): void;
/**
* Set a value at the given index
* @param index - Index of the value to set
* @param value - New value
*/
setValue(index: number, value: number): void;
/**
* Set all values (recalculates ratio if locked, unless all values are zero)
* @param values - New values
*/
setValues(values: number[]): void;
/**
* Get current values
*/
getValues(): number[];
/**
* Get current ratios
*/
getRatios(): number[];
/**
* Check if ratio is locked
*/
isLocked(): boolean;
}
//# sourceMappingURL=ratio-lock.d.ts.map