nodePong/client/lib/ui/objects/ui_rect.js

33 lines
828 B
JavaScript
Raw Normal View History

2016-02-14 07:06:40 +11:00
/**
* @file ui_rect.js
* @author frtk@tetalab
*/
2016-02-14 14:37:31 +11:00
NPGClient.UIRect = function(n, o) {
2016-02-14 07:06:40 +11:00
2016-02-14 10:23:22 +11:00
//
2016-02-16 10:47:28 +11:00
NPGClient.UIObject.call(this, o);
2016-02-14 07:06:40 +11:00
// obj name
this.name = n !== undefined ? n : '';
2016-02-14 14:37:31 +11:00
this.w = o.w !== undefined ? o.w : 0;
this.h = o.h !== undefined ? o.h : 0;
2016-02-14 07:06:40 +11:00
// style
2016-02-14 14:37:31 +11:00
this.style = o.style !== undefined ? o.style : new NPGClient.UIStyle();
2016-02-14 07:06:40 +11:00
};
2016-02-16 10:47:28 +11:00
// inheritance
NPGClient.UIRect.prototype = Object.create(NPGClient.UIObject.prototype);
2016-02-14 07:06:40 +11:00
2016-02-16 10:47:28 +11:00
// Constructor
NPGClient.UIRect.prototype.constructor = NPGClient.UIRect;
NPGClient.UIRect.prototype.draw = function(ctx) {
var self = this;
NPGClient.Utils.applyStyle(ctx, self.style);
if (!self.style.fm) {
NPGClient.Utils.drawRect(ctx, self.x(), self.y(), self.w, self.h);
} else {
NPGClient.Utils.drawFillRect(ctx, self.x(), self.y(), self.w, self.h);
}
2016-02-14 07:06:40 +11:00
};