Emoji Parser
Analizador de emojis para Canvacard.
Emojis
Installing
$ npm i @canvacard/emoji-parser
Example
const Canvas = require("canvas");
const { fillTextWithTwemoji } = require("@canvacard/emoji-parser");
const fs = require("fs");
const canvas = Canvas.createCanvas(500, 270);
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#FFFFFF";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "#FF0000";
ctx.font = "32px Arial";
fillTextWithTwemoji(ctx, "Hello World 😊 <:kek:750253062689652768>", 120, 150)
.then(() => {
fs.writeFileSync("./img.png", canvas.toBuffer())
})
.catch(console.error);
Con Typescript
import { fillTextWithTwemoji } from "@canvacard/emoji-parser";
Preview
Métodos disponibles
fillTextWithEmoji(context: CanvasRenderingContext2D, text: string, x: number, y: number, options?: DrawTextWithEmojiParams): Promise
Renderiza emojis con fillType: "fill"
.
strokeTextWithEmoji(context: CanvasRenderingContext2D, text: string, x: number, y: number, options?: DrawTextWithEmojiParams): Promise
Renderiza emojis con fillType: "stroke"
.
drawTextWithEmoji(context: CanvasRenderingContext2D, fillType: "fill" | "stroke", text: string, x: number, y: number, options?: DrawTextWithEmojiParams): Promise
Método principal utilizado por ambos fillTextWithEmoji
y strokeTextWithEmoji
.