UNPKG

@osbjs/osbjs

Version:

a minimalist osu! storyboarding framework

199 lines (198 loc) 10.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Commandable = void 0; const Component_1 = require("./Component"); const Commands_1 = require("../Commands"); const Enums_1 = require("../Enums"); class Commandable extends Component_1.Component { constructor() { super(); this.commands = []; } /** * Change the opacity of the object. * @param startTime Time in milliseconds/timestamp indicate when the event will start. * @param endTime Time in milliseconds/timestamp indicate when the event will end. * @param startOpacity Opacity at the start of the animation. * @param endOpacity Opacity at the end of the animation. * @param easing How the command should "accelerate". */ Fade(startTime, endTime, startOpacity, endOpacity, easing = Enums_1.Easing.Linear) { this.commands.push(new Commands_1.Command('F', easing, startTime, endTime, startOpacity, endOpacity)); } /** * Shorthand command for `Fade` when `startTime` and `endTime` are equal. * @param time Time in milliseconds/timestamp indicates when the event will occur. * @param opacity Opacity at the given time. */ FadeAtTime(time, opacity) { this.commands.push(new Commands_1.Command('F', Enums_1.Easing.Linear, time, time, opacity, opacity)); } /** * Change the location of the object in the play area. * @param startTime Time in milliseconds/timestamp indicate when the event will start. * @param endTime Time in milliseconds/timestamp indicate when the event will end. * @param startPosition Position at the start of the animation. * @param endPosition Position at the end of the animation. * @param easing How the command should "accelerate". */ Move(startTime, endTime, startPosition, endPosition, easing = Enums_1.Easing.Linear) { this.commands.push(new Commands_1.Command('M', easing, startTime, endTime, startPosition, endPosition)); } /** * Shorthand command for `Move` when `startTime` and `endTime` are equal. * @param time Time in milliseconds/timestamp indicates when the event will occur. * @param position Position at the given time. */ MoveAtTime(time, position) { this.commands.push(new Commands_1.Command('M', Enums_1.Easing.Linear, time, time, position, position)); } /** * Change the X coordinate of the object. * @param startTime Time in milliseconds/timestamp indicate when the event will start. * @param endTime Time in milliseconds/timestamp indicate when the event will end. * @param startX X coordinate at the start of the animation. * @param endX X coordinate at the end of the animation. * @param easing How the command should "accelerate". */ MoveX(startTime, endTime, startX, endX, easing = Enums_1.Easing.Linear) { this.commands.push(new Commands_1.Command('MX', easing, startTime, endTime, startX, endX)); } /** * Shorthand command for `MoveX` when `startTime` and `endTime` are equal. * @param time Time in milliseconds/timestamp indicates when the event will occur. * @param x X coordinate at the given time. */ MoveXAtTime(time, x) { this.commands.push(new Commands_1.Command('MX', Enums_1.Easing.Linear, time, time, x, x)); } /** * Change the Y coordinate of the object. * @param startTime Time in milliseconds/timestamp indicate when the event will start. * @param endTime Time in milliseconds/timestamp indicate when the event will end. * @param startY Y coordinate at the start of the animation. * @param endY Y coordinate at the end of the animation. * @param easing How the command should "accelerate". */ MoveY(startTime, endTime, startY, endY, easing = Enums_1.Easing.Linear) { this.commands.push(new Commands_1.Command('MY', easing, startTime, endTime, startY, endY)); } /** * Shorthand command for `MoveY` when `startTime` and `endTime` are equal. * @param time Time in milliseconds/timestamp indicates when the event will occur. * @param y Y coordinate at the given time. */ MoveYAtTime(time, y) { this.commands.push(new Commands_1.Command('MY', Enums_1.Easing.Linear, time, time, y, y)); } /** * Change the size of the object relative to its original size. * @param startTime Time in milliseconds/timestamp indicate when the event will start. * @param endTime Time in milliseconds/timestamp indicate when the event will end. * @param startScale Scale factor at the start of the animation. * @param endScale Scale factor at the end of the animation. * @param easing How the command should "accelerate". */ Scale(startTime, endTime, startScale, endScale, easing = Enums_1.Easing.Linear) { this.commands.push(new Commands_1.Command('S', easing, startTime, endTime, startScale, endScale)); return this; } /** * Shorthand command for `Scale` when `startTime` and `endTime` are equal. * @param time Time in milliseconds/timestamp indicates when the event will occur. * @param scale Scale factor at the given time. */ ScaleAtTime(time, scale) { this.commands.push(new Commands_1.Command('S', Enums_1.Easing.Linear, time, time, scale, scale)); } /** * Change the size of the object relative to its original size, but X and Y scale separately. * @param startTime Time in milliseconds/timestamp indicate when the event will start. * @param endTime Time in milliseconds/timestamp indicate when the event will end. * @param startScale Scale vector at the start of the animation. * @param endScale Scale vector at the end of the animation. * @param easing How the command should "accelerate". */ ScaleVec(startTime, endTime, startScale, endScale, easing = Enums_1.Easing.Linear) { this.commands.push(new Commands_1.Command('V', easing, startTime, endTime, startScale, endScale)); } /** * Shorthand command for `ScaleVec` when `startTime` and `endTime` are equal. * @param time Time in milliseconds/timestamp indicates when the event will occur. * @param scale Scale vector at the given time. */ ScaleVecAtTime(time, scale) { this.commands.push(new Commands_1.Command('V', Enums_1.Easing.Linear, time, time, scale, scale)); } /** * Change the amount an object is rotated from its original image, in radians, clockwise. * @param startTime Time in milliseconds/timestamp indicate when the event will start. * @param endTime Time in milliseconds/timestamp indicate when the event will end. * @param startAngle Angle to rotate by in radians at the start of the animation. * @param endAngle Angle to rotate by in radians at the end of the animation. * @param easing How the command should "accelerate". */ Rotate(startTime, endTime, startAngle, endAngle, easing = Enums_1.Easing.Linear) { this.commands.push(new Commands_1.Command('R', easing, startTime, endTime, startAngle, endAngle)); } /** * Shorthand command for `Rotate` when `startTime` and `endTime` are equal. * @param time Time in milliseconds/timestamp indicates when the event will occur. * @param angle Angle to rotate by in radians at the given time. */ RotateAtTime(time, angle) { this.commands.push(new Commands_1.Command('R', Enums_1.Easing.Linear, time, time, angle, angle)); } /** * The virtual light source colour on the object. The colours of the pixels on the object are determined subtractively. * @param startTime Time in milliseconds/timestamp indicate when the event will start. * @param endTime Time in milliseconds/timestamp indicate when the event will end. * @param startColor Color at the start of the animation. * Sprites with (255,255,255) will be their original colour and sprites with (0,0,0) will be totally black. * Anywhere in between will result in subtractive colouring. * @param endColor Color at the start of the animation. * Sprites with (255,255,255) will be their original colour and sprites with (0,0,0) will be totally black. * Anywhere in between will result in subtractive colouring. * @param easing How the command should "accelerate". */ Color(startTime, endTime, startColor, endColor, easing = Enums_1.Easing.Linear) { this.commands.push(new Commands_1.Command('C', easing, startTime, endTime, startColor, endColor)); } /** * Shorthand command for `Color` when `startTime` and `endTime` are equal. * @param time Time in milliseconds/timestamp indicates when the event will occur. * @param color Color at the given time. * Sprites with (255,255,255) will be their original colour and sprites with (0,0,0) will be totally black. * Anywhere in between will result in subtractive colouring. */ ColorAtTime(time, color) { this.commands.push(new Commands_1.Command('C', Enums_1.Easing.Linear, time, time, color, color)); } /** * Unlike the other commands, which can be seen as setting endpoints along continually-tracked values, * the `Parameter` command apply ONLY while they are active, * i.e.,you can't put a command from timestamps 1000 to 2000 and expect the value to apply at time 3000, * even if the object's other commands aren't finished by that point. * @param startTime Time in milliseconds/timestamp indicate when the event will start. * @param endTime Time in milliseconds/timestamp indicate when the event will end. * @param parameter `Parameter` to apply. */ Parameter(startTime, endTime, parameter) { this.commands.push(new Commands_1.Command('P', Enums_1.Easing.Linear, startTime, endTime, parameter, parameter)); } /** * Add a loop group to this sprite * @param group A loop group */ Loop(group) { this.commands.push(group); } /** * Add a trigger group to this sprite * @param group A trigger group */ Trigger(group) { this.commands.push(group); } } exports.Commandable = Commandable;