Represents a Point shape.

Hierarchy (view full)

Constructors

  • Creates an instance of Point.

    Parameters

    • x: number = 0

      The x-coordinate of the point. Defaults to 0.

    • y: number = 0

      The y-coordinate of the point. Defaults to 0.

    • kwargs: {} = {}

      Returns Point

    Properties

    attrs: any
    children: Shape[]
    kwargs: any
    tag: string
    transform: Transformation[]
    x: number
    y: number

    Methods

    • Adds a child shape to the current Shape instance.

      Parameters

      • shape: Shape

        A child shape.

      Returns Point

      The current instance of Shape for chaining.

    • Returns a clone of the current Shape instance with new styling information if available.

      Parameters

      • newKwargs: {} = {}

        Key value pairs to provide styling information for a shape. eg { fill: 'red', stroke: 'blue' }.

        Returns Shape

        A new instance of Shape.

      • Checks if the Point passed as the parameter is equal to the current instance.

        Parameters

        • p: Point

          An instance of Point.

        Returns boolean

        A boolean representing whether the current Point instance has the same attributes as the parameter.

      • Repeats the current shape n times by applying transform iteratively.

        Parameters

        • n: number

          A positive integer representing the number of times a shape is to be repeated.

        • transform: Transformation | ((index: number) => TransformationWithStyle) | ((index: number) => Transformation)

          An instance of Transformation that is applied every time the shape is repeated.

        Returns Point

        The current instance of Shape for chaining.

      • Applies a Rotate transformation to the current Shape instance.

        Parameters

        • angle: number = 0

          Amount to rotate clockwise in degrees. Defaults to 0.

        Returns Point

        The current instance of Shape for chaining.

      • Applies a Scale transformation to the current Shape instance.

        Parameters

        • x: number = 1

          Amount to scale along the positive x-axis. Defaults to 1.

        • y: number = 1

          Amount to scale along the positive y-axis. Defaults to 1.

        Returns Point

        The current instance of Shape for chaining.

      • Displays a shape. Steps performed for display are as follows.

        • Apply the transforms that exist on a shape.
        • Apply the styling that exists on a shape.
        • Draw the shape.
        • Draw children shapes.

        Parameters

        • Optionalr: Drawable

          An instance of Drawable.

        Returns void

      • Returns a string representation of Point.

        Returns string

        A string with the name of the shape and its' attributes.

      • Applies a Translate transformation to the current Shape instance.

        Parameters

        • x: number = 0

          Amount to translate along the positive x-axis. Defaults to 0.

        • y: number = 0

          Amount to translate along the positive y-axis. Defaults to 0.

        Returns Point

        The current instance of Shape for chaining.