pixi.js
    Preparing search index...

    Interface PointLike

    Common interface for points with manipulation methods.

    Extends PointData to add operations for copying, comparison and setting values.

    // Basic point manipulation
    const point: PointLike = new Point(10, 20);
    point.set(30, 40);

    // Copy between points
    const other = new Point();
    point.copyTo(other);

    // Compare points
    const same = point.equals(other); // true
    interface PointLike {
        copyFrom: (p: PointData) => this;
        copyTo: <T extends PointLike>(p: T) => T;
        equals: (p: PointData) => boolean;
        set: (x?: number, y?: number) => void;
        x: number;
        y: number;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    copyFrom: (p: PointData) => this

    Copies x and y from the given point

    Type declaration

      • (p: PointData): this
      • Parameters

        Returns this

        Returns itself.

    const point1: PointLike = new Point(10, 20);
    const point2: PointLike = new Point(30, 40);
    point1.copyFrom(point2);
    console.log(point1.x, point1.y); // 30, 40
    copyTo: <T extends PointLike>(p: T) => T

    Copies x and y into the given point

    Type declaration

      • <T extends PointLike>(p: T): T
      • Type Parameters

        Parameters

        • p: T

          The point to copy.

        Returns T

        Given point with values updated

    const point1: PointLike = new Point(10, 20);
    const point2: PointLike = new Point(0, 0);
    point1.copyTo(point2);
    console.log(point2.x, point2.y); // 10, 20
    equals: (p: PointData) => boolean

    Returns true if the given point is equal to this point

    Type declaration

      • (p: PointData): boolean
      • Parameters

        Returns boolean

        Whether the given point equal to this point

    const point1: PointLike = new Point(10, 20);
    const point2: PointLike = new Point(10, 20);
    const point3: PointLike = new Point(30, 40);
    console.log(point1.equals(point2)); // true
    console.log(point1.equals(point3)); // false
    set: (x?: number, y?: number) => void

    Sets the point to a new x and y position. If y is omitted, both x and y will be set to x.

    Type declaration

      • (x?: number, y?: number): void
      • Parameters

        • Optionalx: number

          position of the point on the x axis

        • Optionaly: number

          position of the point on the y axis

        Returns void

    const point: PointLike = new Point(10, 20);
    point.set(30, 40);
    console.log(point.x, point.y); // 30, 40
    point.set(50); // Sets both x and y to 50
    console.log(point.x, point.y); // 50, 50
    x: number

    X coordinate

    y: number

    Y coordinate