UNPKG

fieldkit

Version:

Basic building blocks for computational design projects. Written in CoffeeScript for browser and server environments.

45 lines (31 loc) 897 B
// Generated by CoffeeScript 1.6.3 (function() { var Rect, Vec2; Vec2 = require("./vector").Vec2; Rect = (function() { Rect.prototype.x1 = 0; Rect.prototype.y1 = 0; Rect.prototype.x2 = 0; Rect.prototype.y2 = 0; function Rect(x1, y1, x2, y2) { this.x1 = x1 != null ? x1 : 0; this.y1 = y1 != null ? y1 : 0; this.x2 = x2 != null ? x2 : 0; this.y2 = y2 != null ? y2 : 0; } Rect.prototype.center = function() { var x, y; x = Math.min(this.x1, this.x2) + this.width() * 0.5; y = Math.min(this.y1, this.y2) + this.height() * 0.5; return new Vec2(x, y); }; Rect.prototype.width = function() { return Math.abs(this.x1 - this.x2); }; Rect.prototype.height = function() { return Math.abs(this.y1 - this.y2); }; return Rect; })(); module.exports.Rect = Rect; }).call(this);