mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 06:45:31 +02:00
Transition to @napi-rs/canvas
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const { registerFont } = require('canvas');
|
||||
const { GlobalFonts } = require('@napi-rs/canvas');
|
||||
const weights = {
|
||||
100: 'thin',
|
||||
200: 'extraLight',
|
||||
@@ -28,7 +28,7 @@ module.exports = class Font {
|
||||
register() {
|
||||
if (this.registered) return null;
|
||||
this.registered = true;
|
||||
return registerFont(this.path, { family: this.filenameNoExt, style: this.style, weight: this.weight });
|
||||
return GlobalFonts.registerFromPath(this.path, this.filenameNoExt);
|
||||
}
|
||||
|
||||
toCanvasString(size, shouldDoFallbacks = true) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const request = require('node-superfetch');
|
||||
const { createCanvas } = require('canvas');
|
||||
const { createCanvas } = require('@napi-rs/canvas');
|
||||
const path = require('path');
|
||||
const { removeDuplicates, firstUpperCase, delay } = require('../../util/Util');
|
||||
const { cropToContent } = require('../../util/Canvas');
|
||||
@@ -159,7 +159,7 @@ module.exports = class Pokemon {
|
||||
const y = Math.floor(this.id / 12) * 30;
|
||||
ctx.drawImage(this.store.sprites, x, y, 40, 30, 0, 0, 40, 30);
|
||||
cropToContent(ctx, canvas, canvas.width, canvas.height);
|
||||
return canvas.toBuffer();
|
||||
return canvas.toBuffer('image/png');
|
||||
}
|
||||
|
||||
async fetchSmogonTiers(...gens) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const request = require('node-superfetch');
|
||||
const { loadImage } = require('canvas');
|
||||
const { loadImage } = require('@napi-rs/canvas');
|
||||
const path = require('path');
|
||||
const Pokemon = require('./Pokemon');
|
||||
const MoveStore = require('./MoveStore');
|
||||
|
||||
Reference in New Issue
Block a user