Add: ChocoButton

This commit is contained in:
2019-07-22 11:09:27 +09:00
parent 72a8a39770
commit db2d920589
4 changed files with 385 additions and 12 deletions
@@ -0,0 +1,93 @@
function ChocoButtonSetting(x, y, width, height, roundAmount) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.roundAmount = 0;
if(typeof roundAmount === "undefined") {
var shorterSide = width > height ? height : width;
this.roundAmount = shorterSide * 0.1;
} else {
this.roundAmount = roundAmount;
}
this.strokeWidthPx = ChocoButtonSetting.DEFAULT_STROKE_WIDTH_PX;
this.strokeColors = ChocoButtonSetting.DEFAULT_STROKE_COLORS;
this.buttonColors = ChocoButtonSetting.DEFAULT_BUTTON_COLORS;
this.textColors = ChocoButtonSetting.DEFAULT_TEXT_COLORS;
this.iconColors = ChocoButtonSetting.DEFAULT_ICON_COLORS;
this.fontStyle = ChocoButtonSetting.DEFAULT_TEXT_FONT;
};
ChocoButtonSetting.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;
}
ChocoButtonSetting.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;
}
ChocoButtonSetting.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;
}
ChocoButtonSetting.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;
}
ChocoButtonSetting.DEFAULT_STROKE_COLORS = {
out: 0x666666,
over: 0x333333,
down: 0x333333,
disabled: 0x666666
};
ChocoButtonSetting.DEFAULT_BUTTON_COLORS = {
out: 0xffffff,
over: 0xddffdd,
down: 0xaaffaa,
disabled: 0x333333
};
ChocoButtonSetting.DEFAULT_TEXT_COLORS = {
out: "#000",
over: "#333",
down: "#666",
disabled: "#999"
};
ChocoButtonSetting.DEFAULT_ICON_COLORS = {
out: 0xffffff,
over: 0xddffdd,
down: 0xaaffaa,
disabled: 0x333333
};
ChocoButtonSetting.DEFAULT_TEXT_FONT = {
font: "30px Arial",
boundsAlignH: "center", // left, center. right
boundsAlignV: "middle", // top, middle, bottom
fill: "#fff",
align: "center"
};
ChocoButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX = -10; // in pixel
ChocoButtonSetting.DEFAULT_STROKE_WIDTH_PX = 5; // in pixel