This commit is contained in:
手瓜一十雪
2025-03-26 12:32:54 +08:00
parent 31fdffde36
commit 4d26ec737b
3 changed files with 8 additions and 7 deletions

View File

@@ -43,7 +43,7 @@ export async function drawTimePattern(data: {
const ctx = canvas.getContext('2d');
// 加载背景图
const backgroundImage = await loadImage(path.join(current_path,'.\\fonts\\post.jpg'));
const backgroundImage = await loadImage(path.join(current_path,'./fonts/post.jpg'));
const pattern = ctx.createPattern(backgroundImage, 'repeat');
ctx.fillStyle = pattern;
ctx.fillRect(0, 0, width, height);

View File

@@ -29,7 +29,7 @@ export async function drawJsonContent(jsonContent: string) {
const finalCanvas = createCanvas(width, height);
const finalCtx = finalCanvas.getContext('2d');
const backgroundImage = await loadImage(path.join(current_path,'.\\fonts\\post.jpg'));
const backgroundImage = await loadImage(path.join(current_path,'./fonts/post.jpg'));
const pattern = finalCtx.createPattern(backgroundImage, 'repeat');
finalCtx.fillStyle = pattern;
finalCtx.fillRect(0, 0, width, height);

View File

@@ -1,9 +1,10 @@
import { dirname, join } from 'node:path';
import { NCoreInitShell } from './base';
import { GlobalFonts } from '@napi-rs/canvas';
import { fileURLToPath } from 'node:url';
import { current_path } from '@/plugin/data';
import path from 'path';
let current_path = dirname(fileURLToPath(import.meta.url));
GlobalFonts.registerFromPath(join(current_path, '.\\fonts\\JetBrainsMono.ttf'), 'JetBrains Mono');
GlobalFonts.registerFromPath(join(current_path, '.\\fonts\\AaCute.ttf', 'Aa偷吃可爱长大的'));
GlobalFonts.registerFromPath(path.join(current_path, './fonts/JetBrainsMono.ttf'), 'JetBrains Mono');
GlobalFonts.registerFromPath(path.join(current_path, './fonts/AaCute.ttf'), 'Aa偷吃可爱长大的');
console.log('字体注册完成');
NCoreInitShell();