dotup-ts-node-skills-game
Version:
Develop alexa typescript games
219 lines (217 loc) • 6.04 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const targetLights = ['1'];
class AnimationBuilder {
constructor() {
this.sequences = [];
this.repeat = 1;
}
// FadeIn Animation
static GetFadeInAnimation(repeats, color, duration) {
return {
repeat: repeats,
targetLights: targetLights,
sequence: [
{
durationMs: 1,
blend: true,
color: '000000'
}, {
durationMs: duration,
blend: true,
color: color
}
]
};
}
static GetAnimation(repeat, sequences) {
return {
repeat: repeat,
targetLights: targetLights,
sequence: sequences
};
}
// Solid Animation
static GetSolidAnimation(repeat, color, duration = 500) {
return {
repeat: repeat,
targetLights: targetLights,
sequence: [
{
durationMs: duration,
blend: false,
color: color
}
]
};
}
// FadeIn Animation
static GetFadeAnimation(color, duration = 500) {
return {
repeat: 1,
targetLights: targetLights,
sequence: [
{
durationMs: duration,
blend: true,
color: color
}
]
};
}
// FadeOut Animation
static GetFadeOutAnimation(repeats, color, duration) {
return {
repeat: repeats,
targetLights: targetLights,
sequence: [
{
durationMs: duration,
blend: true,
color: color
}, {
durationMs: 1,
blend: true,
color: '000000'
}
]
};
}
// CrossFade Animation
// tslint:disable-next-line:max-line-length
static GetCrossFadeAnimation(repeats, color1, color2, duration1, duration2) {
return {
repeat: repeats,
targetLights: targetLights,
sequence: [
{
durationMs: duration1,
blend: true,
color: color1
}, {
durationMs: duration2,
blend: true,
color: color2
}
]
};
}
static GetBreatheAnimation(repeats, color, duration) {
return {
repeat: repeats,
targetLights: targetLights,
sequence: [
{
durationMs: 1,
blend: true,
color: '000000'
},
{
durationMs: duration,
blend: true,
color: color
},
{
durationMs: 300,
blend: true,
color: color
},
{
durationMs: 300,
blend: true,
color: '000000'
}
]
};
}
// Blink Animation
static GetBlinkAnimation(repeats, color) {
return {
repeat: repeats,
targetLights: targetLights,
sequence: [
{
durationMs: 500,
blend: false,
color: color
}, {
durationMs: 500,
blend: false,
color: '000000'
}
]
};
}
// Flip Animation
// tslint:disable-next-line:max-line-length
static GetFlipAnimation(repeats, color1, color2, duration1, duration2) {
return {
repeat: repeats,
targetLights: targetLights,
sequence: [
{
durationMs: duration1,
blend: false,
color: color1
}, {
durationMs: duration2,
blend: false,
color: color2
}
]
};
}
// Pulse Animation
static GetPulseAnimation(repeats, color1, color2) {
return {
repeat: repeats,
targetLights: targetLights,
sequence: [
{
durationMs: 500,
blend: true,
color: color1
}, {
durationMs: 1000,
blend: true,
color: color2
}
]
};
}
Repeat(value) {
this.repeat = value;
return this;
}
Sequence(sequence) {
if (Array.isArray(sequence)) {
this.sequences = this.sequences.concat(sequence);
}
else {
this.sequences.push(sequence);
}
return this;
}
Build() {
return {
repeat: this.repeat,
sequence: this.sequences,
targetLights: targetLights
};
}
}
exports.AnimationBuilder = AnimationBuilder;
// // Function to validate the color argument passed. If it's a color name,
// // it compares it to the list of colors defined in the colorList.js,
// // and returns back the Hex code if applicable.
// function validateColor(requestedColor: ButtonColors) {
// const color = requestedColor || '';
// if (color.indexOf('0x') === 0) {
// return color.substring(2);
// } else if (color.indexOf('#') === 0) {
// return color.substring(1);
// } else {
// return requestedColor;
// }
// }
//# sourceMappingURL=AnimationBuilder.js.map