/** * Numbers that carry their unit in the type. At runtime a quantity is * the plain number it was made from, so it compares, sorts and prints * as one and goes wherever a number is wanted. The other direction is * closed: a number becomes a quantity only through the constructors * here, and a quantity in one unit cannot stand in for one in another. * The unit names are the ones the records state in their `unit` field. */ declare const unit: unique symbol; /** * The units a record may state. A `Measure` is limited to these, since * they are what the `unit` field is allowed to say. * @category Format types */ export type Unit = 'mm' | 'cm' | 'px' | 'track' | 's' | 'ms' | 'ft/min' | 'm/min' | 'px/in' | 'deg' | 'percent'; export type Quantity = number & { readonly [unit]: U; }; /** * A place along the roll, or any length on the paper. * @category Units */ export type Millimeters = Quantity<'mm'>; /** * A length in centimetres. * @category Units */ export type Centimeters = Quantity<'cm'>; /** * A place in a scan. Comparable within one scan only, since the resolution is the scan's. * @category Units */ export type Pixels = Quantity<'px'>; /** * A position across the roll, numbered as the tracker bar does. * @category Units */ export type Track = Quantity<'track'>; /** * A time in seconds, such as the moment a performed event falls at. * @category Units */ export type Seconds = Quantity<'s'>; /** * A time in milliseconds. * @category Units */ export type Milliseconds = Quantity<'ms'>; /** * A paper speed in feet per minute. * @category Units */ export type FeetPerMinute = Quantity<'ft/min'>; /** * A paper speed in metres per minute. * @category Units */ export type MetersPerMinute = Quantity<'m/min'>; /** * How finely a scan was read: pixels of the image per inch of paper. * @category Units */ export type Resolution = Quantity<'px/in'>; /** * An angle on the roll, turning from the line across the paper towards the end of the roll. * @category Units */ export type Degrees = Quantity<'deg'>; /** * A share of a length, such as how far the paper has stretched: dimensionless, in hundredths. * @category Units */ export type Percent = Quantity<'percent'>; /** * Names a number in a unit. Partially apply it to make a constructor. * @category Units */ export declare const quantity: (value: number) => Quantity; /** * Names a number in millimetres. * @category Units */ export declare const mm: (value: number) => Quantity<"mm">; /** * Names a number in centimetres. * @category Units */ export declare const cm: (value: number) => Quantity<"cm">; /** * Names a number in pixels of a scan. * @category Units */ export declare const px: (value: number) => Quantity<"px">; /** * Names a number as a position across the roll, as the tracker bar * numbers it. * @category Units */ export declare const track: (value: number) => Quantity<"track">; /** * Names a number in seconds. * @category Units */ export declare const seconds: (value: number) => Quantity<"s">; /** * Names a number in milliseconds. * @category Units */ export declare const milliseconds: (value: number) => Quantity<"ms">; /** * Names a number as a paper speed in feet per minute. * @category Units */ export declare const feetPerMinute: (value: number) => Quantity<"ft/min">; /** * Names a number as a paper speed in metres per minute. * @category Units */ export declare const metersPerMinute: (value: number) => Quantity<"m/min">; /** * Names a number as the resolution of a scan, in pixels per inch. * @category Units */ export declare const pixelsPerInch: (value: number) => Quantity<"px/in">; /** * Names a number as an angle in degrees. * @category Units */ export declare const degrees: (value: number) => Quantity<"deg">; /** * Names a number as a share in per cent. * @category Units */ export declare const percent: (value: number) => Quantity<"percent">; /** * A value together with the unit it was measured in, as a record * states it. * @see crm:E54 Dimension * @category Format types */ export interface Measure { /** * The measured value. * @see crm:P90 has value */ value: Quantity; /** * The unit of measurement. * @see crm:P91 has unit */ unit: U; } /** * The sum of two quantities in one unit. * @internal */ export declare const add: (a: Quantity, b: Quantity>) => Quantity; /** * The first quantity less the second, in their unit. * @internal */ export declare const subtract: (a: Quantity, b: Quantity>) => Quantity; /** * How far apart two quantities in one unit lie, whichever is the * larger. * @internal */ export declare const distance: (a: Quantity, b: Quantity>) => Quantity; /** * A quantity times a plain factor, such as a stretch. * @internal */ export declare const scale: (a: Quantity, factor: number) => Quantity; /** * The smaller of two quantities in one unit. * @internal */ export declare const min: (a: Quantity, b: Quantity>) => Quantity; /** * The larger of two quantities in one unit. * @internal */ export declare const max: (a: Quantity, b: Quantity>) => Quantity; /** * The value brought inside the bounds, which must not be the wrong way round. * @internal */ export declare const clamp: (value: Quantity, low: Quantity>, high: Quantity>) => Quantity; /** * The quantities added up, zero where there are none. * @internal */ export declare const sum: (values: readonly Quantity[]) => Quantity; /** * The mean of the quantities. * @internal */ export declare const mean: (values: readonly Quantity[]) => Quantity; /** * A place in a scan taken at `dpi` dots per inch, on the paper. * @internal */ export declare const inMillimeters: (place: Pixels, dpi: number) => Millimeters; /** * A place on the paper, in a scan taken at `dpi` dots per inch. * @internal */ export declare const inPixels: (place: Millimeters, dpi: number) => Pixels; /** * A length in millimetres, in centimetres. * @internal */ export declare const inCentimeters: (length: Millimeters) => Centimeters; /** * A time in milliseconds, in seconds. * @internal */ export declare const inSeconds: (time: Milliseconds) => Seconds; /** * A time in seconds, in milliseconds. * @internal */ export declare const inMilliseconds: (time: Seconds) => Milliseconds; /** * A speed as a record states it, in feet or metres per minute. * @category Format types */ export type SpeedMeasure = Measure<'ft/min'> | Measure<'m/min'>; /** * A speed in metres per minute, whichever unit it was stated in. * @category Units */ export declare const inMetersPerMinute: (speed: SpeedMeasure) => MetersPerMinute; export {};