UNPKG

companion-module-utils

Version:

Utility tools for use in Bitfocus Companion modules

146 lines (145 loc) 4.58 kB
/// <reference types="node" /> export interface BarColor { size: number; color: number; background: number; backgroundOpacity: number; } type IconType = 'directionDown' | 'directionDownLeft' | 'directionDownRight' | 'directionLeft' | 'directionRight' | 'directionUp' | 'directionUpLeft' | 'directionUpRight' | 'forward' | 'headset1' | 'headset2' | 'headset3' | 'headset4' | 'mic1' | 'mic2' | 'mic3' | 'mic4' | 'mic5' | 'pause' | 'play' | 'playPause' | 'power' | 'record' | 'recordRed' | 'rewind' | 'stop' | 'custom'; export interface Icon { type: IconType; base64: string; argb: number[]; width: number; height: number; } export interface OptionsBar { width: number; height: number; colors: BarColor[]; barLength: number; barWidth: number; value: number; type: 'vertical' | 'horizontal'; offsetX?: number; offsetY?: number; opacity?: number; reverse?: boolean; } export interface OptionsBorder { width: number; height: number; color: number; size: number; opacity?: number; type?: 'border' | 'top' | 'bottom' | 'left' | 'right'; } export interface OptionsCircle { radius: number; color: number; opacity?: number; } export interface OptionsCorner { width: number; height: number; color: number; size?: number; location: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight'; opacity?: number; } export interface OptionsIcon { width: number; height: number; type: IconType | 'Custom'; custom?: Uint8Array; customWidth?: number; customHeight?: number; offsetX?: number; offsetY?: number; } export interface OptionsRect { width: number; height: number; color: number; rectWidth: number; rectHeight: number; strokeWidth: number; fillColor?: number; fillOpacity?: number; offsetX?: number; offsetY?: number; opacity?: number; } export interface OptionParseBase64 { alpha?: boolean; } export interface OptionToPNG64 { image: Buffer | Uint8Array; width: number; height: number; } /** * Generates an image buffer of a bar and calculates the position of the specified value along that bar * * @param options - Required and optional params for the bar * @returns Image buffer containing a bar as per options */ export declare const bar: (options: OptionsBar) => Uint8Array; /** * Generates an image buffer of border * * @param options - Required and optional params for the indicator * @returns Image buffer containing a border indicator as per options */ export declare const border: (options: OptionsBorder) => Uint8Array; /** * Generates an image buffer of a circle at a specified radius. Width and Height are 2 x radius * * @param options - Required and optional params for the indicator * @returns Image buffer containing a circle as per options */ export declare const circle: (options: OptionsCircle) => Uint8Array; /** * Generates an image buffer of a corner indicator * * @param options - Required and optional params for the indicator * @returns Image buffer containing a corner indicator as per options */ export declare const corner: (options: OptionsCorner) => Uint8Array; /** * Generates an image buffer with a specified icon * * @param options - Required and options params for the icon * @returns Image buffer containing an icon as per options */ export declare const icon: (options: OptionsIcon) => Uint8Array; /** * Generates an image buffer of a rectangle * * @param options - Required and optional params for the indicator * @returns Image buffer containing a rectangle as per options */ export declare const rect: (options: OptionsRect) => Uint8Array; /** * Stacks an array of same-size image buffers into a single buffer * * @param buffers - Array of image buffers * @returns A single image buffer */ export declare const stackImage: (buffers: Uint8Array[]) => Uint8Array; /** * Converts a base64 encoded PNG such as that used by png64 feedback into an imagebuffer that can be used with other functions * * @param png64 - base64 encoded PNG string * @param options - Required and optional params * @returns An image buffer */ export declare const parseBase64: (png64: string, options?: OptionParseBase64) => Promise<Uint8Array>; /** * Converts an imageBuffer into a base64 encoded PNG string for use as a buttons png64 styling * * @param options - Required and optional params * @returns An base64 encoded PNG */ export declare const toPNG64: (options: OptionToPNG64) => string; export {};