Function renderTxt2ImgBitmap

  • 将文本渲染为 ImageBitmap,用来创建 ImgClip

    Parameters

    • txt: string

      要渲染的文本

    • cssText: string

      应用于文本的 CSS 样式

    • opts: {
          font?: {
              name: string;
              url: string;
          };
          onCreated?: ((el) => void);
      } = {}

      选项

      • Optional font?: {
            name: string;
            url: string;
        }

        自定义字体

        • name: string
        • url: string
      • Optional onCreated?: ((el) => void)

        创建完成后的回调

          • (el): void
          • Parameters

            • el: HTMLElement

            Returns void

    Returns Promise<ImageBitmap>

    Example

    new ImgClip(
    await renderTxt2ImgBitmap(
    '水印',
    `font-size:40px; color: white; text-shadow: 2px 2px 6px red; font-family: CustomFont;`,
    {
    font: {
    name: 'CustomFont',
    url: '/CustomFont.ttf',
    },
    },
    )
    )