Skip to content

OpenRange

Overview

A numeric range that handles open and half open intervals. Defaults to an open interval.

@author Michael Barlow (PhET Interactive Simulations)

Class OpenRange

import { OpenRange } from 'scenerystack/dot';

Constructor

new OpenRange( min, max, options )

Instance Methods

setMin( min )

OpenRange override for setMin. @public @override @param {number} min

setMax( max )

OpenRange override for setMax. @public @override @param {number} max

setMinMax( min, max )

OpenRange override for setMinMax. Ensures that min is strictly less than max. @override @public @param {number} min @param {number} max

contains( value )

Determines if this range contains the value @public @param {number} value @returns {boolean}

containsRange( range )

Does this range contain the specified range? @public @param {Range} range @returns {boolean}

intersects( range )

Determine if this range overlaps (intersects) with another range @public @param {Range} range @returns {boolean}

toString()

Converts the attributes of this range to a string @public @returns {string}

constrainValue( value )

TODO: how will this function in an open range scenario? https://github.com/phetsims/dot/issues/96 Constrains a value to the range. @public @param {number} value @returns {number}

equals( other )

Determines if this range is equal to other range. @public @param {Range} other @returns {boolean}

Source Code

See the source for OpenRange.js in the dot repository.