Represents a Line shape.

Hierarchy (view full)

Constructors

  • Creates an instance of Line.

    Parameters

    • start: Point = ...

      The first point of the line segment. Defaults to (-100, 0).

    • end: Point = ...

      The second point of the line segment. Defaults to (100, 0)

    • kwargs: {} = {}

      The style information for displaying the rectangle. Defaults to no styling or {}.

      Returns Line

    Properties

    attrs: any
    children: Shape[]
    end: Point
    kwargs: any
    start: Point
    tag: string
    transform: Transformation[]

    Methods

    • Adds a child shape to the current Shape instance.

      Parameters

      • shape: Shape

        A child shape.

      Returns Line

      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.

      • 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 Line

        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 Line

        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 Line

        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 Shape.

        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 Line

        The current instance of Shape for chaining.