1 | import { Point } from './Point';
|
2 | import { ISize } from './ISize';
|
3 | /**
|
4 | * Determines the distance between two points.
|
5 | *
|
6 | * @public
|
7 | */
|
8 | export declare function getDistanceBetweenPoints(point1: Point, point2: Point): number;
|
9 | /**
|
10 | * The available fit modes. These should match the fit modes for CSS.
|
11 | */
|
12 | export declare type FitMode = 'contain' | 'cover';
|
13 | /**
|
14 | * Options for fitting content sizes into bounding sizes.
|
15 | */
|
16 | export interface IFitContentToBoundsOptions {
|
17 | /**
|
18 | * The size of the content to fit to the bounds.
|
19 | * The output will be proportional to this value.
|
20 | */
|
21 | contentSize: ISize;
|
22 | /**
|
23 | * The size of the bounds.
|
24 | */
|
25 | boundsSize: ISize;
|
26 | /**
|
27 | * The fit mode to apply, either 'contain' or 'cover'.
|
28 | */
|
29 | mode: FitMode;
|
30 | /**
|
31 | * An optional maximum scale factor to apply. The default is 1.
|
32 | * Use Infinity for an unbounded resize.
|
33 | */
|
34 | maxScale?: number;
|
35 | }
|
36 | /**
|
37 | * Produces a proportionally-scaled version of an input content size when fit to a bounding size.
|
38 | * Given a `contentSize` and a `boundsSize`, this function scales `contentSize` proportionally
|
39 | * using either `contain` or `cover` fit behaviors.
|
40 | * Use this function to pre-calculate the layout for the CSS `object-fit` and `background-fit` behaviors.
|
41 | * With `contain`, the output size must be the largest it can be while completely within the `boundsSize`.
|
42 | * With `cover`, the output size must be the smallest it can be while completely around the `boundsSize`.
|
43 | * By default, there is a `maxScale` value of 1, which prevents the `contentSize` from being scaled larger.
|
44 | *
|
45 | * @param options - the options for the bounds fit operation
|
46 | */
|
47 | export declare function fitContentToBounds(options: IFitContentToBoundsOptions): ISize;
|
48 | /**
|
49 | * Calculates a number's precision based on the number of trailing
|
50 | * zeros if the number does not have a decimal indicated by a negative
|
51 | * precision. Otherwise, it calculates the number of digits after
|
52 | * the decimal point indicated by a positive precision.
|
53 | * @param value - the value to determine the precision of
|
54 | */
|
55 | export declare function calculatePrecision(value: number | string): number;
|
56 | /**
|
57 | * Rounds a number to a certain level of precision. Accepts negative precision.
|
58 | * @param value - The value that is being rounded.
|
59 | * @param precision - The number of decimal places to round the number to
|
60 | */
|
61 | export declare function precisionRound(value: number, precision: number, base?: number): number;
|