This commit is contained in:
手瓜一十雪 2025-03-19 11:53:53 +08:00
parent 99bfe69752
commit a790303ebe

View File

@ -1,7 +1,7 @@
import { NCoreInitShell } from './base';
import { createCanvas, GlobalFonts, loadImage } from '@napi-rs/canvas';
GlobalFonts.registerFromPath('F:\\fonts\\JetBrainsMono.ttf', 'JetBrains Mono');
GlobalFonts.registerFromPath('F:\\fonts\\AaCute.ttf', 'Aa偷吃可爱长大的');
GlobalFonts.registerFromPath('C:\\fonts\\JetBrainsMono.ttf', 'JetBrains Mono');
GlobalFonts.registerFromPath('C:\\fonts\\AaCute.ttf', 'Aa偷吃可爱长大的');
export async function drawJsonContent(jsonContent: string) {
const lines = jsonContent.split('\n');
@ -30,7 +30,7 @@ export async function drawJsonContent(jsonContent: string) {
const finalCanvas = createCanvas(width, height);
const finalCtx = finalCanvas.getContext('2d');
const backgroundImage = await loadImage('F:\\BVideo\\Dev\\post.jpg');
const backgroundImage = await loadImage('C:\\fonts\\post.jpg');
const pattern = finalCtx.createPattern(backgroundImage, 'repeat');
finalCtx.fillStyle = pattern;
finalCtx.fillRect(0, 0, width, height);