rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
97 lines (48 loc) • 1.72 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [rc-js-util](./rc-js-util.md) > [Range2d](./rc-js-util.range2d.md) > [scaleRelativeTo](./rc-js-util.range2d.scalerelativeto.md)
## Range2d.scaleRelativeTo() method
Scales the range relative to a point (may not be outside of the range).
**Signature:**
```typescript
scaleRelativeTo<TResult extends TTypedArray = TArray>(_scalingFactor: number, _relativeTo: IReadonlyVec2<TTypedArray>, _result?: Range2d<TResult>): Range2d<TResult>;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
\_scalingFactor
</td><td>
number
</td><td>
</td></tr>
<tr><td>
\_relativeTo
</td><td>
[IReadonlyVec2](./rc-js-util.ireadonlyvec2.md)<!-- --><[TTypedArray](./rc-js-util.ttypedarray.md)<!-- -->>
</td><td>
</td></tr>
<tr><td>
\_result
</td><td>
[Range2d](./rc-js-util.range2d.md)<!-- --><TResult>
</td><td>
_(Optional)_
</td></tr>
</tbody></table>
**Returns:**
[Range2d](./rc-js-util.range2d.md)<!-- --><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-------------|
|-------------|
```