UNPKG

@sputnick/lumiere

Version:

A styled component library used in my videos

169 lines (165 loc) 6.99 kB
import { Rect, RectProps } from '@motion-canvas/2d/lib/components'; import { SimpleSignal, SignalValue } from '@motion-canvas/core/lib/signals'; import { PossibleColor, ColorSignal } from '@motion-canvas/core/lib/types'; import * as _motion_canvas_core_lib_threading from '@motion-canvas/core/lib/threading'; import { ThreadGenerator, Promisable } from '@motion-canvas/core/lib/threading'; /** * An enum for highlighting a value, label or both * @remarks * This is used as a value for subject in {@link HighlightProps} */ declare enum HighlightSubject { Label = 0, Value = 1, Both = 2 } /** * An interface for providing arguments to the * {@link ArrayEntry.highlight} method. * * @param Color - The color to highlight in * @param Subject - The subject to highlight * @param Duration - The duration of animation (in seconds) * @param HighlightBorder - If true, this will highlight the node's * border in the specified highlight color. * @see {@link HighlightSubject} */ interface HighlightProps { Color?: PossibleColor; Subject?: HighlightSubject; Duration?: number; HighlightBorder?: boolean; } interface EntryProps extends RectProps { index: SignalValue<number>; value: SignalValue<string | number>; label?: SignalValue<string | number>; } declare class ArrayEntry extends Rect { readonly index: SimpleSignal<number, this>; readonly value: SimpleSignal<number | string, this>; readonly label: SimpleSignal<number | string, this>; private readonly ref; constructor(props: EntryProps); highlightBorder(highlightColor?: PossibleColor, duration?: number): Generator<void | ThreadGenerator | Promise<any> | _motion_canvas_core_lib_threading.Promisable<any>, void, any>; private highlightText; highlightLabel(highlightColor?: PossibleColor, duration?: number): Generator<void | ThreadGenerator | Promise<any> | _motion_canvas_core_lib_threading.Promisable<any>, void, any>; highlightValue(highlightColor?: PossibleColor, duration?: number): Generator<void | ThreadGenerator | Promise<any> | _motion_canvas_core_lib_threading.Promisable<any>, void, any>; /** * Highlights a node with a * specified color. * * @see {@link HighlightProps} */ highlight(options?: HighlightProps): ThreadGenerator; } /** * Used for setting the label * of each value in the array */ interface LabeledArray { [key: string]: string | number; } declare const isLabeledArray: (checkObj: number[] | string[] | LabeledArray) => checkObj is LabeledArray; declare function toLabeledArray(a: number[] | string[] | LabeledArray): LabeledArray; /** * `Top` - Renders the name on the top of the array * * `Bottom` - Renders the name on the bottom of the array * * @remarks note: the name will be centred horizontally */ declare enum Align { Top = 0, Botom = 1 } /** * @param values - The values of the array * @param name - The name of the array * @param suffix - The suffix of the name * @param suffixColor - Used for coloring the * suffix * @param align - The alignment of the array's name * * @see {@link LabeledArray}, {@link Align} * * @remarks suffix is usually used * to show the type of the array * such as the name `intArr int[]` * where `int[]` is the suffix. */ interface ArrayProps extends RectProps { values: SignalValue<number[] | string[] | LabeledArray>; name?: SignalValue<string>; suffix?: SignalValue<string>; suffixColor?: SignalValue<PossibleColor>; align?: SignalValue<Align>; } declare class Array extends Rect { readonly values: SimpleSignal<number[] | string[] | LabeledArray, this>; readonly name: SimpleSignal<string, this>; readonly suffix: SimpleSignal<string, this>; readonly suffixColor: ColorSignal<this>; readonly align: SimpleSignal<Align, this>; boxArray: SimpleSignal<ArrayEntry[], this>; private pool; /** * An array component used for * containing characters and * numerical values. * * @see {@link ArrayProps} */ constructor(props?: ArrayProps); /** * Highlight a node in the array * @param Index - The index of the node * that will be highlighted * * @see {@link HighlightProps} */ highlight(index: number, props: HighlightProps): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>; /** * Highlight just the border of a node * in the array. * @param index - The index of the node * who's border will be highlighted * @param color - The color to highlight in * @param duration - The duration (in seconds) * of the highlight animation */ highlightBorder(index: number, color?: PossibleColor, duration?: number): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>; /** * Animate the swap of two nodes in the * array component. * * @param index1 - The first node's index * @param index2 - The second node's index * @param duration - The duration (in seconds) of the swap animation */ swap(index1: number, index2: number, duration?: number): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>; /** * Swap two node's positions and highlight them before * doing so * * @param index1 - The first node's index * @param index2 - The Second node's index * @param props - {@link HighlightProps} * @param swapDuration - The animation duration (in seconds) of * _just_ the swap and _not_ the highlight animation period. * @param segment - If true, highlight each node in * sequence and then swap, rather than highlighting * both simultaneously * * @remarks note that `swapDuration` and `props.Duration` are * different and serve different functions. `props.Duration` * specified the time taken to highlight the nodes. `swapDuration` * specified the time to swap the positions of the two nodes. */ swapAndHighlight(index1: number, index2: number, props?: HighlightProps, swapDuration?: number, segment?: boolean): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>; push(value: string | number, duration?: number): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>; chainPush(values: string[] | number[], duration?: number): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>; pop(n?: number, duration?: number): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>; chainPop(n: number, duration?: number): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>; } export { Align, Array, ArrayProps, LabeledArray, isLabeledArray, toLabeledArray };