number/grid#

Functions#

clampValue()#

clampValue(value, start, end): Rational

Defined in: number/grid.ts:124

value held to [start, end]; an end of null (unknown) holds only below.

Parameters#

value#

Rational

start#

Rational

end#

Real | null

Returns#

Rational


nearest()#

nearest(value, denominator): Rational

Defined in: number/grid.ts:26

The nearest multiple of 1 / denominator to value, a tie going up.

Parameters#

value#

Rational

denominator#

bigint

Returns#

Rational


snapValue()#

snapValue(value, reach, numberType, granularity): Rational

Defined in: number/grid.ts:107

The value a pointer picks at value on an axis of numberType, reach being half a device pixel on that axis:

  • fraction: for each divisor d of granularity.denominator, ascending, the nearest k/d to value (a tie going up); the first within reach wins; none: the nearest multiple of 1 / denominator.

  • float: for n from 0 to granularity.decimals, value rounded to n decimal places (a tie going up), as an exact decimal; the first within reach wins; none: decimals places.

  • int: for 10^m from the largest power of ten not above 2·reach (at least 1) down to 1, the nearest multiple of 10^m (a tie going up); the first within reach wins; none: the nearest integer.

Parameters#

value#

Rational

reach#

Rational

numberType#

NumberType

granularity#

Granularity

Returns#

Rational

Throws#

if reach is not positive.