UNPKG

@ginden/blinkstick-v2

Version:
65 lines 2.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Animation = void 0; const pulse_1 = require("./common/pulse"); const repeat_1 = require("./helpers/repeat"); const color_input_to_rgb_tuple_1 = require("../utils/colors/color-input-to-rgb-tuple"); const morph_1 = require("./common/morph"); const morph_many_1 = require("./common/morph-many"); const assert_fps_below_100_1 = require("./helpers/assert-fps-below-100"); /** * Bag of static methods for creating animations. * @category Animation */ class Animation { /** * This class is not meant to be instantiated. * @private */ constructor() { } /** * Shorthand for `repeat` * @param animation * @param repeatCount */ static repeat(animation, repeatCount) { return (0, repeat_1.repeat)(animation, repeatCount); } /** * Shorthand for `repeat(pulse(color, overMs, steps), repeatCount)` */ static pulse(color, overMs, steps = overMs / 17, repeatCount = 1) { (0, assert_fps_below_100_1.assertFpsBelow100)(overMs, steps); const actualColorTuple = (0, color_input_to_rgb_tuple_1.colorInputToRgbTuple)(color); const pulseIterator = (0, pulse_1.pulse)(actualColorTuple, { steps, overMs }); if (repeatCount === 1) { return pulseIterator; } return (0, repeat_1.repeat)(pulseIterator, repeatCount); } /** * Shorthand for `morph(from, to, overMs, steps)` * @param from * @param to * @param overMs * @param steps */ static morph(from, to, overMs, steps = overMs / 17) { (0, assert_fps_below_100_1.assertFpsBelow100)(overMs, steps); const baseRgb = (0, color_input_to_rgb_tuple_1.colorInputToRgbTuple)(from); const targetRgb = (0, color_input_to_rgb_tuple_1.colorInputToRgbTuple)(to); return (0, morph_1.morph)(baseRgb, targetRgb, overMs, steps); } /** * Shorthand for `morphMany(tuples, overMs, steps)` * @param tuples * @param overMs * @param steps */ static morphMany(tuples, overMs, steps = overMs / 17) { (0, assert_fps_below_100_1.assertFpsBelow100)(overMs, steps); return (0, morph_many_1.morphMany)(tuples.map(color_input_to_rgb_tuple_1.colorInputToRgbTuple), overMs, steps); } } exports.Animation = Animation; //# sourceMappingURL=animation-description.js.map