function ButtonSetting(x, y, width, height) { this.x = x; this.y = y; this.width = width; this.height = height; this.strokeWidthPx = 0; this.roundAmount = 0; this.fontSize = 10; this.strokeColors = ButtonSetting.DEFAULT_STROKE_COLORS; this.buttonColors = ButtonSetting.DEFAULT_BUTTON_COLORS; this.textColors = ButtonSetting.DEFAULT_TEXT_COLORS; this.iconColors = ButtonSetting.DEFAULT_ICON_COLORS; this.fontStyle = ButtonSetting.DEFAULT_TEXT_FONT; }; ButtonSetting.prototype.setRound = function(round) { if(this.width / 2 > round && this.height / 2 > round) { this.roundAmount = round; return this.roundAmount; } var maxRound = round; if(this.width > this.height) { maxRound = this.height / 2; } else { maxRound = this.width / 2; } this.roundAmount = maxRound; } ButtonSetting.prototype.setStrokeWidth = function(width) { if(this.width / 2 > width && this.height / 2 > width) { this.strokeWidthPx = width; return this.strokeWidthPx; } var maxWidth = width; if(this.width > this.height) { maxWidth = this.height / 2; } else { maxWidth = this.width / 2; } this.strokeWidthPx = maxWidth; } ButtonSetting.prototype.setFont = function(fontName) { this.font = fontName; } ButtonSetting.prototype.setFontSize = function(size) { this.fontSize = size; } ButtonSetting.prototype.setStrokeColor = function(out, over, down, disabled) { this.strokeColors = { }; this.strokeColors.out = out; this.strokeColors.over = over; this.strokeColors.down = down; this.strokeColors.disabled = disabled; } ButtonSetting.prototype.setButtonColor = function(out, over, down, disabled) { this.buttonColors = { }; this.buttonColors.out = out; this.buttonColors.over = over; this.buttonColors.down = down; this.buttonColors.disabled = disabled; } ButtonSetting.prototype.setTextColor = function(out, over, down, disabled) { this.textColors = { }; this.textColors.out = out; this.textColors.over = over; this.textColors.down = down; this.textColors.disabled = disabled; } ButtonSetting.prototype.setIconColor = function(out, over, down, disabled) { this.iconColors = { }; this.iconColors.out = out; this.iconColors.over = over; this.iconColors.down = down; this.iconColors.disabled = disabled; } ButtonSetting.DEFAULT_STROKE_COLORS = { out: 0x666666, over: 0x333333, down: 0x333333, disabled: 0x666666 }; ButtonSetting.DEFAULT_BUTTON_COLORS = { out: 0xffffff, over: 0xddffdd, down: 0xaaffaa, disabled: 0x333333 }; ButtonSetting.DEFAULT_TEXT_COLORS = { out: "#000", over: "#333", down: "#666", disabled: "#999" }; ButtonSetting.DEFAULT_ICON_COLORS = { out: 0xffffff, over: 0xddffdd, down: 0xaaffaa, disabled: 0x333333 }; ButtonSetting.DEFAULT_TEXT_FONT = { font: "30px", boundsAlignH: "center", // left, center. right boundsAlignV: "middle", // top, middle, bottom fill: "#fff", align: "center" }; ButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX = -10; // in pixel ButtonSetting.DEFAULT_STROKE_WIDTH_PX = 5; // in pixel