import { z } from 'zod'; import { numeric } from '../../numeric'; import { bounds } from '../bounds'; import { Box } from '../box/box'; import { dimensions } from '../dimensions'; import { location } from '../location'; import { xy } from '../xy'; export declare const crudeXYTransform: z.ZodObject<{ offset: z.ZodUnion, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodObject<{ width: z.ZodNumber; height: z.ZodNumber; }, z.core.$strip>, z.ZodObject<{ signedWidth: z.ZodNumber; signedHeight: z.ZodNumber; }, z.core.$strip>, z.ZodObject<{ clientX: z.ZodNumber; clientY: z.ZodNumber; }, z.core.$strip>]>; scale: z.ZodUnion, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodObject<{ width: z.ZodNumber; height: z.ZodNumber; }, z.core.$strip>, z.ZodObject<{ signedWidth: z.ZodNumber; signedHeight: z.ZodNumber; }, z.core.$strip>, z.ZodObject<{ clientX: z.ZodNumber; clientY: z.ZodNumber; }, z.core.$strip>]>; }, z.core.$strip>; export type XYTransformT = z.infer; export declare const transform: z.ZodObject<{ offset: z.ZodNumber; scale: z.ZodNumber; }, z.core.$strip>; export type TransformT = { offset: T; scale: T; }; export type BoundVariant = "domain" | "range"; type ValueType = "position" | "dimension"; type Operation = (currScale: bounds.Bounds | null, type: ValueType, value: T, reverse: boolean) => OperationReturn; type OperationReturn = [bounds.Bounds | null, T]; interface TypedOperation extends Operation { type: "translate" | "magnify" | "scale" | "invert" | "clamp" | "re-bound"; } /** * Scale implements a chain of operations that can be used to transform numeric values. * A scale can either operate on standard JS numbers or on BigInts, but not both. */ export declare class Scale { ops: TypedOperation[]; currBounds: bounds.Bounds | null; currType: ValueType | null; private reversed; constructor(); /** * @returns a new scale with a translation as its first operation. Any number provided * to the {@link pos} operation on the scale will be translated by the specified value. * @param value - The amount to translate by. */ static translate(value: T): Scale; /** * @returns a new scale with a magnification as its first operation. Any number provided * to the {@link pos} or {@link dim} operation will be multiplied by the specified value. * @param value - The amount to translate by. */ static magnify(value: T): Scale; /** * @returns a new scale that uses the given lower and upper bounds as it's initial * scale. This scale will be used to define the initial 'band' of values defined within * the scale. Once the scale is created, call {@link scale} again to scale the initial * band to the new scaled band. * * @example * const s = Scale.scale(1).scale(100) * console.log(s.pos(0)) * // 0 * console.log(s.pos(1)) * // 100 * * @param upper - The upper bound of the scale. This overload assumes that the lower * bound is 0. */ static scale(upper: T): Scale; /** * @returns a new scale that uses the given lower and upper bounds as it's initial * scale. This scale will be used to define the initial 'band' of values defined within * the scale. Once the scale is created, call {@link scale} again to scale the initial * band to the new scaled band. * * @example * const s = Scale.scale(0, 1).scale(0, 100) * console.log(s.pos(0)) * // 0 * console.log(s.pos(1)) * // 100 * * @param lower - The lower bound of the scale. * @param upper - The upper bound of the scale. */ static scale(lower: T, upper: T): Scale; /** * @returns a new scale that uses the given bounds as it's initial * scale. This scale will be used to define the initial 'band' of values defined within * the scale. Once the scale is created, call {@link scale} again to scale the initial * band to the new scaled band. * * @example * const s = Scale.scale({ lower: 0, upper: 1 }).scale({lower: 0, upper: 100 }) * console.log(s.pos(0)) * // 0 * console.log(s.pos(1)) * // 100 * * @param bound - The bound to scale by. See {@link bounds.Bounds} for more info. */ static scale(bound: bounds.Bounds): Scale; /** * @returns a copy of the scale with a translation as its next operation. Any * number provided to the {@link pos} method on the scale will be translated by the * specified value. * @param value - The amount to translate by. */ translate(value: T): Scale; /** * @returns a copy of the scale with a translation as its next operation. Any number * provided to the {@link pos} or {@link dim} method on the scale will be multiplied * by the specified value. * @param value - The amount to magnify by. */ magnify(value: T): Scale; /** * @returns a copy of the scale with a 're-scaling' as its next operation. This will * translate numbers provided to {@link pos} and {@link dim} to the new scale. * * @example * const s = Scale.scale(1).scale(100) * console.log(s.pos(0)) * // 0 * console.log(s.pos(1)) * // 100 * * @param upper - The upper bound of the scale. This overload assumes that the lower * bound is 0. */ scale(upper: T): Scale; /** * @returns a copy of the scale with a 're-scaling' as its next operation. This will * translate numbers provided to {@link pos} and {@link dim} to the new scale. * * @example * const s = Scale.scale(0, 1).scale(0, 100) * console.log(s.pos(0)) * // 0 * console.log(s.pos(1)) * // 100 * * @param lower - The lower bound of the new scale. * @param upper - The upper bound of the new scale. */ scale(lower: T, upper: T): Scale; /** * @returns a copy of the scale with a 're-scaling' as its next operation. This will * translate numbers provided to {@link pos} and {@link dim} to the new scale. * * @example * const s = Scale.scale({ lower: 0, upper: 1 }).scale({lower: 0, upper: 100 }) * console.log(s.pos(0)) * // 0 * console.log(s.pos(1)) * // 100 * * @param bound - The bound to scale by. See {@link bounds.Bounds} for more info. */ scale(bounds: bounds.Bounds): Scale; /** This overload is for internal use only */ scale(upperOrBound: T | bounds.Bounds, upper?: T): Scale; /** * @returns a copy of the scale with a clamping operation applied. Any number passed * to the scale wil be clamped to the specified bounds. * * @example * const s = Scale.scale(0, 1).clamp(0, 0.5) * console.log(s.pos(1)) * // 0.5 * * @param upper - The upper bound to clamp by. WARNING: This operation assumes * that the lower bound of the clamp is 0. */ clamp(upper: T): Scale; /** * @returns a copy of the scale with a clamping operation applied. Any number passed * to the scale wil be clamped to the specified bounds. * * @example * const s = Scale.scale(0, 1).clamp(0, 0.5) * console.log(s.pos(1)) * // 0.5 * * @param lower - The lower bound of the scale. * @param upper - The upper bound of the scale. */ clamp(lower: T, upper: T): Scale; /** * @returns a copy of the scale with a clamping operation applied. Any number passed * to the scale will be clamped to the specified bounds. * * @example * const s = Scale.scale(0, 1).clamp({ lower: 0, upper: 0.5 }) * console.log(s.pos(1)) * // 0.5 * * @param bounds - The bounds to clamp by. */ clamp(bounds: bounds.Bounds): Scale; /** * @returns a copy of the scale with a re-bounding operation applied. This operation * adjusts the bounds of the scale WITHOUT applying a scaling operation to values * passed through the scale. * * @example * const s = Scale.scale(0, 1).reBound(0, 100) * console.log(s.bound) * * @param lower - The new lower bound. * @param upper - The new upper bound. */ reBound(lower: T, upper?: T): Scale; /** * @returns a copy of he scale with a re-bounding operation applied. This operation * * @param bound */ reBound(bound: bounds.Bounds): Scale; invert(): Scale; pos(v: T): T; dim(v: T): T; private new; private exec; reverse(): Scale; get transform(): TransformT; static readonly IDENTITY: Scale; } export declare class XY { x: Scale; y: Scale; currRoot: location.Corner | null; constructor(x?: Scale, y?: Scale, root?: location.Corner | null); static translate(xy: number | xy.XY, y?: number): XY; static translateX(x: number): XY; static translateY(y: number): XY; static clamp(box: Box): XY; static magnify(xy: xy.XY): XY; static scale(box: dimensions.Dimensions | Box): XY; static reBound(box: Box): XY; translate(cp: number | xy.Crude, y?: number): XY; translateX(x: number): XY; translateY(y: number): XY; magnify(xy: xy.XY): XY; scale(b: Box | dimensions.Dimensions): XY; reBound(b: Box): XY; clamp(b: Box): XY; copy(): XY; reverse(): XY; pos(xy: xy.XY): xy.XY; dim(xy: xy.XY): xy.XY; box(b: Box): Box; get transform(): XYTransformT; static readonly IDENTITY: XY; } export {}; //# sourceMappingURL=scale.d.ts.map