Nutrient Web SDK
    Preparing search index...

    A point describes a 2D vector in space consisting of an x and y coordinate. Provided values are defined in same units used by the page, point units. Point units are only equal to pixels when zoom value is 1.

    It is an https://facebook.github.io/immutable-js/docs/#/Record|Immutable.Record and thus can be updated using set(key, value), for example: point.set("x", 20).

    Create and update a point.

    const point = new NutrientViewer.Geometry.Point({ x: 20, y: 30 });
    point = point.set("y", 20);
    point.y; // => 20

    An object used to initialize the Point. If x or y is omitted, 0 will be used instead.

    { x: 0, y: 0 }
    

    Hierarchy

    Indexable

    • readonly [key: string]: unknown
    Index

    Constructors

    • Parameters

      • Optionaloptions: { x?: number; y?: number; [k: string]: unknown }

      Returns NutrientViewer.Geometry.Point

    Properties

    x: number

    The x coordinate of the point.

    0
    
    y: number

    The y coordinate of the point.

    0
    
    defaultValues: IObject = ...

    Methods

    • Returns IterableIterator<
          [keyof { x?: number; y?: number; [k: string]: unknown }, unknown],
      >

    • Returns this

      Map#asImmutable

    • Returns this

      Map#asMutable

    • Returns a new instance of this Record type with all values set to their default values.

      Returns this

    • Returns a new instance of this Record type with the value for the specific key set to its default value.

      Type Parameters

      • K extends keyof { x?: number; y?: number; [k: string]: unknown }

      Parameters

      • key: K

      Returns this

      remove

    • Parameters

      Returns this

      removeIn

    • Calculates the euclidean distance to another point.

      Parameters

      • other: this

        The other point to calculate the distance with.

      Returns number

      The distance between the two points.

      var point1 = new NutrientViewer.Geometry.Point({ x: 10, y: 10 });
      var point2 = new NutrientViewer.Geometry.Point({ x: 20, y: 10 });
      point1.distance(point2); // => 10
    • Parameters

      • other: any

      Returns boolean

    • Returns the value associated with the provided key, which may be the default value defined when creating the Record factory function.

      If the requested key is not defined by this Record type, then notSetValue will be returned if provided. Note that this scenario would produce an error when using Flow or TypeScript.

      Type Parameters

      • K extends keyof { x?: number; y?: number; [k: string]: unknown }

      Parameters

      • key: K
      • OptionalnotSetValue: any

      Returns { x?: number; y?: number; [k: string]: unknown }[K]

    • Type Parameters

      • T

      Parameters

      • key: string
      • notSetValue: T

      Returns T

    • Parameters

      Returns any

    • Parameters

      • key: string

      Returns key is string

    • Returns number

    • Parameters

      Returns boolean

    • Parameters

      • ...collections: (
            | Iterable<[string, any]>
            | Partial<{ x?: number; y?: number; [k: string]: unknown }>
        )[]

      Returns this

    • Parameters

      • ...collections: (
            | Iterable<[string, any]>
            | Partial<{ x?: number; y?: number; [k: string]: unknown }>
        )[]

      Returns this

    • Parameters

      • keyPath: Iterable<any>
      • ...collections: any[]

      Returns this

    • Parameters

      • merger: (oldVal: any, newVal: any, key: any) => any
      • ...collections: (
            | Iterable<[string, any]>
            | Partial<{ x?: number; y?: number; [k: string]: unknown }>
        )[]

      Returns this

    • Parameters

      • keyPath: Iterable<any>
      • ...collections: any[]

      Returns this

    • Parameters

      • merger: (
            oldVal: any,
            newVal: any,
            key: keyof { x?: number; y?: number; [k: string]: unknown },
        ) => any
      • ...collections: (
            | Iterable<[string, any]>
            | Partial<{ x?: number; y?: number; [k: string]: unknown }>
        )[]

      Returns this

    • Type Parameters

      • K extends keyof { x?: number; y?: number; [k: string]: unknown }

      Parameters

      • key: K

      Returns this

    • Parameters

      Returns this

    • Rotates the point at the origin [0, 0].

      Parameters

      • deg: number

      Returns this

    • Scales x and y by the given sx and sy factor. If only sx is set and sy not defined, it will scale x and y by sx.

      Parameters

      • sx: number

        Scale value for the x coordinate. If sy is not set, this scale will also be applied to y.

      • Optionalsy: number

        If empty, it will scale y with sx as well.

      Returns this

      A new Point.

      const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 });
      point.scale(2); // => Point {x: 20, y: 20}
    • Type Parameters

      • K extends keyof { x?: number; y?: number; [k: string]: unknown }

      Parameters

      • key: K
      • value: { x?: number; y?: number; [k: string]: unknown }[K]

      Returns this

    • Parameters

      Returns this

    • Deeply converts this Record to equivalent native JavaScript Object.

      Note: This method may not be overridden. Objects with custom serialization to plain JS may override toJSON() instead.

      Returns { x?: any; y?: any; [key: string]: any }

    • Shallowly converts this Record to equivalent native JavaScript Object.

      Returns { x?: number; y?: number; [k: string]: unknown }

    • Shallowly converts this Record to equivalent JavaScript Object.

      Returns { x?: number; y?: number; [k: string]: unknown }

    • Returns Keyed<keyof { x?: number; y?: number; [k: string]: unknown }, unknown>

    • Translate all values of the point by a given Point.

      Parameters

      • point: { x: number; y: number }

        A point that describes the translation distance.

      Returns this

      A new Point.

      const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 });
      point.translate(new NutrientViewer.Geometry.Point({ x: 5, y: -5 })); // => Point {x: 15, y: 5}
    • Translate the x value by a given number.

      Parameters

      • tx: number

        A number to translate the x value.

      Returns this

      A new Point.

      const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 });
      point.translateX(5); // => Point {x: 15, y: 10}
    • Translate the y value by a given number.

      Parameters

      • ty: number

        A number to translate the y value.

      Returns this

      A new Point.

      const point = new NutrientViewer.Geometry.Point({ x: 10, y: 10 });
      point.translateY(5); // => Point {x: 10, y: 15}
    • Type Parameters

      • K extends keyof { x?: number; y?: number; [k: string]: unknown }

      Parameters

      • key: K
      • updater: (
            value: { x?: number; y?: number; [k: string]: unknown }[K],
        ) => { x?: number; y?: number; [k: string]: unknown }[K]

      Returns this

    • Parameters

      • keyPath: Iterable<any>
      • updater: (value: any) => any

      Returns this

    • Returns boolean

      Map#wasAltered

    • Note: Not all methods can be used on a mutable collection or within withMutations! Only set may be used mutatively.

      Parameters

      • mutator: (mutable: this) => any

      Returns this

      Map#withMutations