Creates an interval from two values.
The start of the interval. Could either be the interval's min or max. If the interval is increasing, this should be the min.
The end of the interval. Could either be the interval's min or max value. If the interval is increasing, this should be the max.
Gets the start of the interval.
Gets the end of the interval.
Finds the overlapping portion of two intervals and returns the resulting interval.
An interval representing the overlap between these two intervals. If there is no overlap, returns undefined.
Converts the interval into an IntervalSorted and returns the sorted interval.
Checks whether a value is within the interval.
The value to check for containment.
The amount the value can be outside the interval and still be considered inside.
Checks whether the value is within the interval and returns the result using the PointContainment enum. The value will be considered coincident if it equals the interval's min or max.
The value to check for containment.
The distance the value can be from the interval's min or max and still considered coincident.
The interval to compare against.
Creates a copy of this interval expanded to contain a given value. The direction of the interval, whether it is increasing or decreasing, will be preserved. Depending on where the value falls in relation to the interval, either T0 or T1 will change to accommodate the value.
Value to contain within the new interval.
Remaps a value from the global number system into the normalized parameters of this interval. See valueAt to understand how the parameters are calculated.
Value to remap to the parameter of the interval.
The value as a normalized parameter for the interval.
Gets the interval as a string in the format: [T0,T1]
.
Remaps a value from normalized parameters of this interval into the global number system. The interval's parameters range from 0 to 1.
A parameter of 0 is equal to the start of the interval (T0). A parameter of 0.5 is the mid point of the interval. And a parameter of 1 is the end of the interval (T1).
The parameter to remap.
The parameter remapped to the global number system.
Creates a copy of the interval with a different T0 value.
Creates a copy of the interval with a different T1 value.
Generated using TypeDoc
A number range between two values (T0 & T1). This range is increasing when T0 < T1 and decreasing when T0 > T1.
Example
import { Interval } from 'shapetypes' // Create an interval const interval = new Interval(5, 10); // Get properties of the interval console.log(interval.length); // => 5 console.log(interval.mid); // => 7.5 console.log(interval.contains(8)); // => True console.log(interval.isIncreasing); // => True // Create the same interval but in reverse const reversed = new Interval(10, 5); // Get properties of the reversed interval console.log(reversed.length); // => -5 console.log(reversed.contains(8)); // => True console.log(reversed.isIncreasing); // => False