唐润平:上线版,功能为待完善

This commit is contained in:
trp
2023-12-14 10:26:29 +08:00
parent e95c24befe
commit fb9dfb37a2
21 changed files with 701 additions and 489 deletions

View File

@@ -0,0 +1,15 @@
/**
* @param {String} text 把输入的文字转化为base64的img图片
*/
export default function (text, width = 100, height = 50) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "white";
ctx.fillRect(0, 0, width, height);
ctx.fillStyle = "black";
ctx.font = "30px serif";
ctx.fillText(text, 0, 30);
return canvas.toDataURL();
}