/** * @file ui_rect.js * @author frtk@tetalab */ NPGClient.UIRect = function(n, o) { // NPGClient.UIShape.call(this); // obj name this.name = n !== undefined ? n : ''; // geom this.pos = o.pos !== undefined ? o.pos : {}; this.w = o.w !== undefined ? o.w : 0; this.h = o.h !== undefined ? o.h : 0; // style this.style = o.style !== undefined ? o.style : new NPGClient.UIStyle(); }; NPGClient.UIRect.prototype = { // Constructor constructor: NPGClient.UIRect, // draw: function(ctx) { var self = this; if (!self.style.fm) { self.drawNoFill(ctx, self.pos.x, self.pos.y, self.w, self.h, self.style.lw, self.style.lc); } else { self.drawFill(ctx, self.pos.x, self.pos.y, self.w, self.h, self.style.fc); } }, // drawFill: function(ctx) { var self = this; NPGClient.Utils.applyStyle(ctx, self.style); ctx.fillRect(self.pos.x, self.pos.y, self.w, self.h); }, // drawNoFill: function(ctx, x1, y1, w, h, lw, c) { var self = this; ctx.beginPath(); NPGClient.Utils.applyStyle(ctx, self.style); ctx.rect(self.pos.x, self.pos.y, self.w, self.h); ctx.stroke(); }, };