dfcreative/mucss

View on GitHub
rect.js

Summary

Maintainability
A
0 mins
Test Coverage
/**
 * Simple rect constructor.
 * It is just faster and smaller than constructing an object.
 *
 * @module mucss/rect
 *
 * @param {number} l left
 * @param {number} t top
 * @param {number} r right
 * @param {number} b bottom
 *
 * @return {Rect} A rectangle object
 */
module.exports = function Rect (l,t,r,b) {
    if (!(this instanceof Rect)) return new Rect(l,t,r,b);

    this.left=l||0;
    this.top=t||0;
    this.right=r||0;
    this.bottom=b||0;
    this.width=Math.abs(this.right - this.left);
    this.height=Math.abs(this.bottom - this.top);
};