js-util

Home > rc-js-util > Range2d > scaleRelativeTo

Range2d.scaleRelativeTo() method

Scales the range relative to a point (may not be outside of the range).

Signature:

scaleRelativeTo<TResult extends TTypedArray = TArray>(_scalingFactor: number, _relativeTo: IReadonlyVec2<TTypedArray>, _result?: Range2d<TResult>): Range2d<TResult>;

Parameters

Parameter Type Description
_scalingFactor number  
_relativeTo IReadonlyVec2<TTypedArray>  
_result Range2d<TResult> (Optional)

Returns:

Range2d<TResult>

Remarks

If the point is at a boundary, then the range will be scaled such that that boundary is not changed. Where the point is away from a boundary, the updated range will have boundaries proportional to the distance from the center of the range.

E.g. scaling factor of 0.5, P represents the position of the point in the range:

XMin                      XMax
 |P-------------------------|
 |-------------|

 |------------P-------------|
       |-------------|