UNPKG

ddnet

Version:

A typescript npm package for interacting with data from ddnet.org

171 lines (170 loc) 3.7 kB
import sharp from 'sharp'; import { MasterServerClient } from '../../Master.js'; import { HSLA_Color } from './Color.js'; /** * Tee skin eye variants */ export declare enum TeeSkinEyeVariant { normal = "eye-normal", angry = "eye-angry", pain = "eye-pain", happy = "eye-happy", /** * Unused, some 0.6 skins have them though */ dead = "eye-dead", surprise = "eye-surprise", blink = "eye-blink" } /** * Gets width and height from an image buffer. * * @internal */ export declare function getImgSize( /** * The image buffer to get dimensions from. */ buf: Buffer): Promise<{ width: number; height: number; }>; /** * For the tee body * Reorder that the average grey is 192 * * @see * https://github.com/ddnet/ddnet/blob/master/src/game/client/components/skins.cpp#L224-L260 * * @internal */ export declare function reorderBody( /** * The buffer to work on. */ buf: Buffer): Promise<{ data: Buffer; info: sharp.OutputInfo; }>; /** * Converts a buffer to grayscale. */ export declare function convertToGrayscale( /** * The buffer to work on. */ buf: Buffer, /** * If the buffer should be reordered by the {@link reorderBody} function. */ reorder?: boolean): Promise<{ data: Buffer; info: sharp.OutputInfo; }>; /** * Tint a buffer with a given HSLA color. */ export declare function tint( /** * The buffer to work on. */ buf: Buffer, /** * The HSLA color to tint the buffer with. */ hsla: HSLA_Color, /** * Set to true for tinting 0.7 skins. */ use7UnclampVal?: boolean, /** * Wether to allow working with the alpha channel. */ allowAlpha?: boolean): Promise<{ data: Buffer; info: sharp.OutputInfo; }>; /** * Skin rendering options */ export interface TeeSkinRenderOptions { /** * The eye variant to render with. * * @default * "eye-default" */ eyeVariant?: TeeSkinEyeVariant; /** * Custom colors to use in TW color code format. * * @remarks * Both TW color codes for feet and body must be provided for 0.6 skins. */ customColors?: { /** * TW code for the body color. */ bodyTWcode?: number | null; /** * TW code for the marking color. */ markingTWcode?: number | null; /** * TW code for the decoration color. */ decorationTWcode?: number | null; /** * TW code for the feet color. */ feetTWcode?: number | null; /** * TW code for the eyes color. */ eyesTWcode?: number | null; }; /** * If provided, will save the output buffer as a png to the specified path. * * @example * "./skins/output.png" */ saveFilePath?: string | null; /** * The size in pixels of the final image. * * @default * 96 */ size?: number; /** * The angle in degrees at which the tee should be looking * * @remarks * 0 is right * * @default * 0 */ viewAngle?: number; } /** * Helper function to quickly render any tee using the skin data from any client on any server reported by the master server. Custom colors are automatically handled. */ export declare function renderTee( /** * The skin data to use. */ skinData: MasterServerClient['skin'], /** * Render options excluding custom colors. */ renderOpts?: Omit<TeeSkinRenderOptions, 'customColors'>): Promise<Buffer>; /** * Deep Required type * * @internal */ export type DeepRequired<T extends object> = Required<{ [P in keyof T]: T[P] extends object | undefined ? DeepRequired<Required<T[P]>> : T[P]; }>;