hammerspoon2-docs
    Preparing search index...

    Class HSSize

    This is a JavaScript object used to represent the size of a rectangle, as used in various places throughout Hammerspoon's API, particularly where dealing with portions of a display. Behind the scenes it is a wrapper for the CGSize type in Swift/ObjectiveC.

    Index

    Constructors

    Properties

    h w

    Methods

    Constructors

    • Create a new HSSize object

      Parameters

      • w: number

        The width of the rectangle

      • h: number

        The height of the rectangle

      Returns HSSize

    Properties

    h: number

    The height of the rectangle

    w: number

    The width of the rectangle

    Methods

    • Returns the angle between the positive x axis and this size, treated as a vector of (w, h)

      Returns number

      A number containing the angle in radians

    • Checks if this size is equal to another size

      Parameters

      • other: HSSize

        An HSSize to compare against

      Returns boolean

      true if both sizes have the same width and height, otherwise false

    • Truncates the width and height of this size towards negative infinity

      Returns HSSize

      A new HSSize with the w and h values floored to the nearest integer

    • Scales this size

      Parameters

      • factor: number | HSSize | HSPoint

        A number to scale both dimensions uniformly, or an HSSize/HSPoint to scale the width and height independently

      Returns HSSize

      A new HSSize scaled by the given factor, or an unchanged copy of this size if factor is not a number, HSSize or HSPoint