Base class representing shape Implement common methods of affine transformations

Type Parameters

Hierarchy (view full)

Constructors

Accessors

  • get box(): Box
  • Bounding box

    Returns Box

    bounding box of a shape

  • get name(): string
  • Shape name

    Returns string

    name of the shape

Methods

  • Get a cloned shape

    Returns T

    clone of a shape

  • Get distance to shape.

    Parameters

    Returns [number, Segment]

  • Rotate shape by given angle around given center point. If center point is omitted, rotates around zero point (0,0). Positive value of angle defines rotation in counterclockwise direction, negative angle defines rotation in clockwise direction

    Parameters

    • angle: number

      angle in radians

    • center: SimplePoint = ...

      center of rotation

    Returns T

    new rotated shape

  • Scale shape with coordinates multiplied by scaling factor

    Parameters

    • sx: number

      x-axis scaling factor

    • sy: number

      y-axis scaling factor

    Returns T

    new scaled shape

  • Transform shape with given affine transformation matrix.

    Parameters

    Returns T

    new transformed shape

  • Translated shape by given vector. Translation vector may be also defined by a pair of numbers.

    Parameters

    • Rest...args: [number, number] | [Vector]

      Translation vector or translation by x and y or tuple of numbers

    Returns T

    new translated shape