@pilotlab/lux-attributes
Version:
A luxurious user experience framework, developed by your friends at Pilot.
141 lines • 6.38 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var lux_attributes_1 = require("@pilotlab/lux-attributes");
var point_1 = require("./point");
var lux_attributes_2 = require("@pilotlab/lux-attributes");
var Rectangle = (function (_super) {
__extends(Rectangle, _super);
function Rectangle(x, y, width, height, label) {
if (x === void 0) { x = 0; }
if (y === void 0) { y = 0; }
if (width === void 0) { width = 1; }
if (height === void 0) { height = 1; }
var _this = _super.call(this, 'Rectangle', null, lux_attributes_1.DataType.COLLECTION, label) || this;
_this.p_x = _this.children.get('x', x, lux_attributes_1.DataType.NUMBER_DOUBLE, label, lux_attributes_1.AttributeChangeOptions.zero);
_this.p_y = _this.children.get('y', y, lux_attributes_1.DataType.NUMBER_DOUBLE, label, lux_attributes_1.AttributeChangeOptions.zero);
_this.p_width = _this.children.get('width', width, lux_attributes_1.DataType.NUMBER_DOUBLE, label, lux_attributes_1.AttributeChangeOptions.zero);
_this.p_height = _this.children.get('height', height, lux_attributes_1.DataType.NUMBER_DOUBLE, label, lux_attributes_1.AttributeChangeOptions.zero);
return _this;
}
Object.defineProperty(Rectangle.prototype, "copy", {
get: function () { return new Rectangle(this.x, this.y, this.width, this.height); },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "x", {
get: function () { return this.p_x.value; },
set: function (value) { this.p_x.set(value, lux_attributes_1.AttributeChangeOptions.save.durationZero); },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "left", {
get: function () { return this.x; },
set: function (value) { this.x = value; },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "right", {
get: function () { return this.x + this.width; },
set: function (value) { this.x = value - this.width; },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "y", {
get: function () { return this.p_y.value; },
set: function (value) { this.p_y.set(value, lux_attributes_1.AttributeChangeOptions.save.durationZero); },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "top", {
get: function () { return this.y; },
set: function (value) { this.y = value; },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "bottom", {
get: function () { return this.y + this.height; },
set: function (value) { this.y = value - this.height; },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "width", {
get: function () { return this.p_width.value; },
set: function (value) { this.p_width.set(value, lux_attributes_1.AttributeChangeOptions.save.durationZero); },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "height", {
get: function () { return this.p_height.value; },
set: function (value) { this.p_height.set(value, lux_attributes_1.AttributeChangeOptions.save.durationZero); },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "topLeft", {
get: function () { return new point_1.default(this.left, this.top); },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "topRight", {
get: function () { return new point_1.default(this.right, this.top); },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "bottomLeft", {
get: function () { return new point_1.default(this.left, this.bottom); },
enumerable: true,
configurable: true
});
Object.defineProperty(Rectangle.prototype, "bottomRight", {
get: function () { return new point_1.default(this.right, this.bottom); },
enumerable: true,
configurable: true
});
Rectangle.prototype.intersects = function (rectangle) {
return !(rectangle.left > this.right
|| rectangle.right < this.left
|| rectangle.top > this.bottom
|| rectangle.bottom < this.top);
};
Rectangle.prototype.has = function (rectangle) {
return (rectangle.left > this.left
&& rectangle.right < this.right
&& rectangle.top > this.top
&& rectangle.bottom < this.bottom);
};
Rectangle.prototype.canFit = function (rectangle) {
return (this.width >= rectangle.width
&& this.height >= rectangle.height);
};
Rectangle.prototype.go = function (target, durationSpeed, ease, repeatCount) {
if (repeatCount === void 0) { repeatCount = 0; }
var options = new lux_attributes_1.AttributeChangeOptions(lux_attributes_2.AttributeChangeActions.SIGNAL_CHANGE, durationSpeed, ease);
options.repeatCount = repeatCount;
return this.attributes.update(target, options);
};
Object.defineProperty(Rectangle, "empty", {
get: function () {
var rectangle = new Rectangle();
rectangle.x = null;
rectangle.y = null;
rectangle.width = null;
rectangle.height = null;
return rectangle;
},
enumerable: true,
configurable: true
});
return Rectangle;
}(lux_attributes_1.Attribute));
exports.Rectangle = Rectangle;
exports.default = Rectangle;
//# sourceMappingURL=rectangle.js.map