shimi
Version:
A JS framework for building complex MIDI applications
50 lines (49 loc) • 1.78 kB
TypeScript
/**
* The Range class represents a one-dimensional range, going from some start value to some end value.
*
* Within the rest of the shimi architecture, this is most often used as a way to represent some range of time.
*/
export default class Range {
/**
* The value which the range starts at.
*
* Attempts to set this to a value greater than `end` will result in an error being thrown.
*/
get start(): number;
set start(value: number);
private _start;
/**
* The difference between the `start` and `end` values.
*
* Attempts to set this to a negative value will result in an error being thrown.
*/
get duration(): number;
set duration(value: number);
private _duration;
/**
* The value which the range ends at.
*
* Attempts to set this to a value less than `start` will result in an error being thrown.
*/
get end(): number;
set end(value: number);
/**
* @param start The value which the range starts at.
* @param duration The duration of the range.
*/
constructor(start: number, duration: number);
/**
* Accepts a value and returns what percentage of the way into the range that the value is.
*
* The returned value can be negative, or greater than 100%, if the passed in value is less than the range start, or greater than the range end.
* @param value The value to compare against the range.
* @returns
*/
getPercent(value: number): number;
/**
* Returns true if the passed in point is greater than or equal to range start, and less than or equal to range end.
* @param point The point value to determine whether it's within the range.
* @returns
*/
contains(point: number): boolean;
}