gradum-kit - v0.1.0
    Preparing search index...

    Class Point

    Index
    • Returns Point

      Create a point with coordinates (0, 0)

    • Parameters

      • n: number

        The input value

      Returns Point

      Create a point with coordinates (n, n)

    • Parameters

      • x: number

        The x coordinate

      • y: number

        The y coordinate

      Returns Point

      Create a point with coordinates (x, y)

    • Parameters

      • e: { clientX: number; clientY: number }

        The coordinates

      Returns Point

      Create a point with the clientX/clientY values. Useful for events.

    • Parameters

      Returns Point

      Create a point with the provided coordinates

    • Parameters

      • arr: [number, number]

        The array of size 2.

      Returns Point

      Create a point with the provided [x, y] values.

    • Parameters

      • x: number | Coordinate | [number, number] | { clientX: number; clientY: number }

      Returns Point

    x: number

    The point's x coordinate. Points are immutable — the arithmetic methods return new points rather than changing this one.

    y: number

    The point's y coordinate.

    • get object(): Coordinate

      Returns Coordinate

      This point as a plain {x, y} object, detached from this instance.

    • get abs(): Point

      Returns Point

      A new point with both coordinates made positive. This point is left unchanged.

      Calculate the absolute value of the coordinates

    • get max(): number

      Returns number

      The larger of the two coordinates.

      Get the maximum value between x and y coordinates

    • get min(): number

      Returns number

      The smaller of the two coordinates.

      Get the minimum value between x and y coordinates

    • get length2(): number

      Returns number

      The squared distance from the origin to this point. Cheaper than Function.length since it skips the square root — use it when comparing magnitudes.

    • get length(): number

      Returns number

      The distance from the origin to this point.

    • Parameters

      Returns number

      Calculate the distance between two Position2D points.

    • Parameters

      • ...arr: Coordinate[]

        Undetermined number of point parameters

      Returns Point

      Calculate the mid-point from the provided points

    • Parameters

      • ...arr: Coordinate[]

        Undetermined number of point parameters

      Returns Point

      Calculate the max on both x and y from the provided points

    • Parameters

      • ...arr: Coordinate[]

        Undetermined number of point parameters

      Returns Point

      Calculate the min on both x and y from the provided points

    • Parameters

      • p: Coordinate

        The coordinates to compare against.

      Returns boolean

      Whether both coordinates match.

      Determine whether this point is equal to the given coordinates.

    • Parameters

      • x: number

        The x coordinate to compare against.

      • y: number

        The y coordinate to compare against.

      Returns boolean

      Whether both coordinates match.

      Determine whether this point is equal to the given coordinates.

    • Function

      boundX

      Parameters

      • x1: number

        The lower bound.

      • x2: number

        The upper bound.

      Returns number

      The clamped x coordinate. This point is left unchanged.

      Clamp this point's x coordinate to a range.

    • Function

      boundY

      Parameters

      • y1: number

        The lower bound.

      • y2: number

        The upper bound.

      Returns number

      The clamped y coordinate. This point is left unchanged.

      Clamp this point's y coordinate to a range.

    • Function

      bound

      Parameters

      • n1: number

        The lower bound for both axes.

      • n2: number

        The upper bound for both axes.

      Returns Point

      A new clamped point. This point is left unchanged.

      Clamp both coordinates to the same range.

    • Function

      bound

      Parameters

      • x1: number

        The lower bound for x.

      • x2: number

        The upper bound for x.

      • Optionaly1: number

        The lower bound for y. Defaults to the x bound.

      • Optionaly2: number

        The upper bound for y. Defaults to the x bound.

      Returns Point

      A new clamped point. This point is left unchanged.

      Clamp each coordinate to its own range.

    • Parameters

      • n: number

        The value to add to both x and y

      Returns Point

      A new point holding the result. This point is left unchanged.

      Add coordinates to this point

    • Parameters

      • x: number

        The value to add to the x coordinate

      • y: number

        The value to add to the y coordinate

      Returns Point

      A new point holding the result. This point is left unchanged.

      Add coordinates to this point

    • Parameters

      Returns Point

      A new point holding the result. This point is left unchanged.

      Add coordinates to this point

    • Parameters

      • n: number

        The value to subtract from both x and y

      Returns Point

      A new point holding the result. This point is left unchanged.

      Subtract coordinates from this point

    • Parameters

      • x: number

        The value to subtract from the x coordinate

      • y: number

        The value to subtract from the y coordinate

      Returns Point

      A new point holding the result. This point is left unchanged.

      Subtract coordinates from this point

    • Parameters

      Returns Point

      A new point holding the result. This point is left unchanged.

      Subtract coordinates from this point

    • Parameters

      • n: number

        The value to multiply both x and y

      Returns Point

      A new point holding the result. This point is left unchanged.

      Multiply coordinates of this point

    • Parameters

      • x: number

        The value to multiply the x coordinate

      • y: number

        The value to multiply the y coordinate

      Returns Point

      A new point holding the result. This point is left unchanged.

      Multiply coordinates of this point

    • Parameters

      Returns Point

      A new point holding the result. This point is left unchanged.

      Multiply coordinates of this point

    • Parameters

      • n: number

        The value to divide both x and y

      Returns Point

      A new point holding the result. This point is left unchanged.

      Divide coordinates of this point

    • Parameters

      • x: number

        The value to divide the x coordinate

      • y: number

        The value to divide the y coordinate

      Returns Point

      A new point holding the result. This point is left unchanged.

      Divide coordinates of this point

    • Parameters

      Returns Point

      A new point holding the result. This point is left unchanged.

      Divide coordinates of this point

    • Parameters

      • n: number

        The value to mod both x and y

      Returns Point

      A new point holding the result. This point is left unchanged.

      Mod coordinates of this point

    • Parameters

      • x: number

        The value to mod the x coordinate

      • y: number

        The value to mod the y coordinate

      Returns Point

      A new point holding the result. This point is left unchanged.

      Mod coordinates of this point

    • Parameters

      Returns Point

      A new point holding the result. This point is left unchanged.

      Mod coordinates of this point

    • Function

      dot

      Parameters

      • p: Point

        The other vector.

      Returns number

      The dot product. Zero means the two are perpendicular.

      Compute the dot product of this point and another, treating both as vectors.

    • Returns Point

      A new point with the same coordinates.

      Create a copy of the current point

    • Returns number[]

      A two-element array, [x, y].

      Get the coordinates as an array

    • Function

      positionOnSegment

      Parameters

      • start: Point

        The segment's start.

      • end: Point

        The segment's end.

      Returns number

      A value from 0 (at the start) to 1 (at the end), clamped to that range. Returns 0 for a zero-length segment.

      Find how far along a segment this point projects, as a fraction from its start to its end. Useful for snapping a position onto a line.

    • Function

      linearInterpolation

      Parameters

      • start: Point

        The point at t = 0.

      • end: Point

        The point at t = 1.

      • t: number

        The interpolation fraction. Values outside 0–1 extrapolate past the ends.

      Returns Point

      The interpolated point.

      Interpolate between two points.

    • Function

      toString

      Returns string

      The serialized point, e.g. '{"x":1,"y":2}'.

      Serialize this point to a JSON string, in the form Point.fromString reads.

    • Function

      from

      Parameters

      • value: string

        The string to parse.

      Returns Point

      The parsed point, or undefined if the string is not valid JSON holding numeric x and y fields.

      Parse a point from a JSON string produced by Function.toString.

    • Function

      fromString

      Parameters

      • value: string

        The string to parse.

      Returns Point

      The parsed point, or undefined if the string is not valid JSON holding numeric x and y fields.

      Parse a point from a JSON string produced by Function.toString. Delegates to Point.from; it exists as an instance method because GradumInput discovers a value's parser by looking for fromString on the value itself, which a static member would not satisfy.