@dan-uni/dan-any
Version:
A danmaku transformer lib, supporting danmaku from different platforms.
72 lines (71 loc) • 1.79 kB
TypeScript
import type { CanvasRenderingContext2D as NodeCRCtx2D } from 'canvas';
import type { UniDM } from '../utils/dm-gen';
/**
* 请根据您的使用环境提供一个 50x50 的 2D Canvas 上下文
* @example
* // Node.js + canvas
* import { createCanvas } from 'canvas'
* const canvas = createCanvas(50, 50)
* const ctx = canvas.getContext('2d')
* @example
* // Node.js + Fabric.js
* import { StaticCanvas } from 'fabric/node'
* const ctx = new StaticCanvas(null, { width: 50, height: 50 }).getContext()
* @example
* // Browser + Native Canvas
* const canvas = document.createElement('canvas')
* canvas.width = 50
* canvas.height = 50
* const ctx = canvas.getContext('2d')
* @example
* // Browser + Fabric.js
* import { Canvas } from 'fabric'
* const ctx = new Canvas('canvas', { width: 50, height: 50 }).getContext()
*/
export type CanvasCtx = NodeCRCtx2D | CanvasRenderingContext2D;
export interface Context {
filename: string;
title: string;
}
export interface SubtitleStyle {
fontSize: number[];
fontName: string;
color: string;
outlineColor?: string;
backColor?: string;
outline: number;
shadow: number;
bold: boolean;
padding: number[];
playResX: number;
playResY: number;
scrollTime: number;
fixTime: number;
opacity: number;
bottomSpace: number;
includeRaw: boolean;
mergeIn: number;
}
export type RGB = {
r: number;
g: number;
b: number;
};
export declare const DanmakuType: {
SCROLL: number;
BOTTOM: number;
TOP: number;
};
export declare const FontSize: {
SMALL: number;
NORMAL: number;
LARGE: number;
};
export type Danmaku = {
time: number;
type: number;
fontSizeType: number;
color: RGB;
content: string;
extra: UniDM;
};