UNPKG

shimi

Version:

A JS framework for building complex MIDI applications

547 lines (546 loc) 20.4 kB
/** * ITween defines an interface which forms the basis for an object that supports a gradual transition between 2 values. * * @category Tweens */ export interface ITween { /** The value to start the tween from. */ get from(): number; /** The value to end the tween at. */ get to(): number; /** * Accepts a percent value and returns a corresponding value somewhere between the `from` and `to` values. * @param percent Expects a value ranging from 0 to 1. */ update(percent: number): number; /** * Allows for tweens to be chained one after another. * @param tween The next tween to follow after the current one. * @param weight Weighting to determine how much of the tweening time that the new tween gets. */ then(tween: ITween, weight?: number): ITween; /** Used by the library for the custom serialization of tween objects */ toJSON(): any; } /** * LinearTween defines a constant movement between 2 values. * * @category Tweens */ export declare class LinearTween implements ITween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** The value to start the tween from. */ get from(): number; private _from; /** The value to end the tween at. */ get to(): number; private _to; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Accepts a percent value and returns a corresponding value somewhere between the `from` and `to` values. * @param percent Expects a value ranging from 0 to 1. */ update(percent: number): number; /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; /** * Allows for tweens to be chained one after another. * @param tween The next tween to follow after the current one. * @param weight Weighting to determine how much of the tweening time that the new tween gets. */ then(tween: ITween, weight?: number): ITween; toJSON(): { type: string; from: number; to: number; }; } /** * MultiTween supports multiple tweens being chained one after another. * * @category Tweens */ export declare class MultiTween implements ITween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; private _children; /** * @param firstChild The first tween in the chain. */ constructor(firstChild: ITween, weight?: number); /** The value to start the tween from. */ get from(): number; /** The value to end the tween at. */ get to(): number; /** * Accepts a percent value and returns a corresponding value somewhere between the `from` and `to` values. * @param percent Expects a value ranging from 0 to 1. */ update(percent: number): number; /** * Allows for tweens to be chained one after another. * @param tween The next tween to be added to the chain. * @param weight Weighting to determine how much of the tweening time that the new tween gets. */ then(tween: ITween, weight?: number): ITween; toJSON(): { type: string; children: any[]; }; } /** * SineInOutTween defines an eased movement between 2 values. * * @category Tweens */ export declare class SineInOutTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * SineInTween defines an eased movement between 2 values. * * @category Tweens */ export declare class SineInTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * SineOutTween defines an eased movement between 2 values. * * @category Tweens */ export declare class SineOutTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * StepsTween defines a step-wise movement between 2 values. * * @category Tweens */ export declare class StepsTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * How many step movements to take in getting to the destination value. */ get steps(): number; set steps(value: number); private _steps; /** * @param from The value to start the tween from. * @param to The value to end the tween at. * @param steps How many step movements to take in getting to the destination value. */ constructor(from: number, to: number, steps: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; steps: number; }; } /** * QuadraticInOutTween defines an eased movement between 2 values. * * @category Tweens */ export declare class QuadraticInOutTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * QuadraticInTween defines an eased movement between 2 values. * * @category Tweens */ export declare class QuadraticInTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * QuadraticOutTween defines an eased movement between 2 values. * * @category Tweens */ export declare class QuadraticOutTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * CubicInOutTween defines an eased movement between 2 values. * * @category Tweens */ export declare class CubicInOutTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * CubicInTween defines an eased movement between 2 values. * * @category Tweens */ export declare class CubicInTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * CubicOutTween defines an eased movement between 2 values. * * @category Tweens */ export declare class CubicOutTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * QuarticInOutTween defines an eased movement between 2 values. * * @category Tweens */ export declare class QuarticInOutTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * QuarticInTween defines an eased movement between 2 values. * * @category Tweens */ export declare class QuarticInTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * QuarticOutTween defines an eased movement between 2 values. * * @category Tweens */ export declare class QuarticOutTween extends LinearTween { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** * @param from The value to start the tween from. * @param to The value to end the tween at. */ constructor(from: number, to: number); /** * Represents the equation of how the tween value changes over time. Think of a cartesian graph, where the x-axis is time as a percent, and the y-axis is how far in its journey as a percent from `from` to `to` the tween is. * @param percent Expects a value ranging from 0 to 1 * @returns Should return a value ranging from 0 to 1 */ tweenEquation(percent: number): number; toJSON(): { type: string; from: number; to: number; }; } /** * The Tween class contains static methods for slightly more nice and intuitive creation of tweens. * * @category Tweens */ export default class Tween { /** * Creates a new instance of MultiTween * @param firstChild The first child to make up the multi-tween * @param weight How much weight the first child gets within the overall tween * @returns */ static multi(firstChild: ITween, weight?: number): MultiTween; /** * Creates a new instance of LinearTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static linear(from: number, to: number): LinearTween; /** * Creates a new instance of SineInOutTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static sineInOut(from: number, to: number): SineInOutTween; /** * Creates a new instance of SineInTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static sineIn(from: number, to: number): SineInTween; /** * Creates a new instance of SineOutTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static sineOut(from: number, to: number): SineOutTween; /** * Creates a new instance of StepsTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static steps(from: number, to: number, steps: number): StepsTween; /** * Creates a new instance of QuadraticInOutTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static quadraticInOut(from: number, to: number): QuadraticInOutTween; /** * Creates a new instance of QuadraticInTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static quadraticIn(from: number, to: number): QuadraticInTween; /** * Creates a new instance of QuadraticOutTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static quadraticOut(from: number, to: number): QuadraticOutTween; /** * Creates a new instance of CubicInOutTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static cubicInOut(from: number, to: number): CubicInOutTween; /** * Creates a new instance of CubicInTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static cubicIn(from: number, to: number): CubicInTween; /** * Creates a new instance of CubicOutTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static cubicOut(from: number, to: number): CubicOutTween; /** * Creates a new instance of QuarticInOutTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static quarticInOut(from: number, to: number): QuarticInOutTween; /** * Creates a new instance of QuarticInTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static quarticIn(from: number, to: number): QuarticInTween; /** * Creates a new instance of QuarticOutTween. * @param from The value to start the tween from. * @param to The value to end the tween at. * @returns */ static quarticOut(from: number, to: number): QuarticOutTween; /** Takes an object parsed from JSON Tween data to load into an actual tween instance. */ static load(tweenData: any): LinearTween | MultiTween; }