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

52 lines
897 B
JavaScript

/**
* @file ui_style.js
* @author frtk@tetalab
*/
NPGClient.UIStyle = function(fm, fc, bm, bw, bc) {
this.fm = fm !== undefined ? fm : false;
this.fc = fc !== undefined ? fc : '';
this.bm = bm !== undefined ? bm : false;
this.bw = bw !== undefined ? bw : 0;
this.bc = bc !== undefined ? bc : '';
};
NPGClient.UIStyle.prototype = {
constructor: NPGClient.UIStyle,
borderMode: function() {
return this.bm;
},
fillMode: function() {
return this.fm;
},
setBorders: function(m, w, c) {
this.bm = m;
this.bw = w;
this.bc = c;
},
setFillStyle: function(m, c) {
this.fm = m;
this.fc = c;
},
applyStyle: function(ctx) {
var self = this;
// fill style
if (fm == true) ctx.fillStyle = self.fc;
// border mode
if (bm == true) {
ctx.lineWidth = bw;
ctx.strokeStyle = bc;
}
}
};