mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-12 01:36:54 +02:00
feat: add script to reproduce emoji rendering to a PNG image file.
This commit is contained in:
1 parent
f321f6f108
commit
6be8bbf628
1 file changed
+32
@@ -0,0 +1,32 @@
|
||||
|
||||
import { emojiRenderer } from "./services/emojiRenderer";
|
||||
import { createCanvas } from "canvas";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
async function run() {
|
||||
const width = 500;
|
||||
const height = 200;
|
||||
const canvas = createCanvas(width, height);
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
ctx.fillStyle = "white";
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
||||
ctx.fillStyle = "black";
|
||||
ctx.font = "30px Arial";
|
||||
|
||||
const text = "Hello 🌍 World! 😂";
|
||||
console.log(`Rendering text: ${text}`);
|
||||
|
||||
try {
|
||||
await emojiRenderer.drawText(text, ctx, 50, 100, 30);
|
||||
const buffer = canvas.toBuffer("image/png");
|
||||
fs.writeFileSync("emoji_test.png", buffer);
|
||||
console.log("Image saved to emoji_test.png");
|
||||
} catch (error) {
|
||||
console.error("Error rendering emoji:", error);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in new issue
Block a user