mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 06:42:51 +02:00
Use font in sos
This commit is contained in:
Binary file not shown.
@@ -1,9 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'SunDried.ttf'), { family: 'Sun Dried' });
|
||||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
|
|
||||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
|
|
||||||
|
|
||||||
module.exports = class SosCommand extends Command {
|
module.exports = class SosCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -47,7 +45,7 @@ module.exports = class SosCommand extends Command {
|
|||||||
const canvas = createCanvas(base.width, base.height);
|
const canvas = createCanvas(base.width, base.height);
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.drawImage(base, 0, 0);
|
ctx.drawImage(base, 0, 0);
|
||||||
ctx.font = '90px Noto';
|
ctx.font = '90px Sun Dried';
|
||||||
ctx.fillStyle = 'black';
|
ctx.fillStyle = 'black';
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.textBaseline = 'middle';
|
ctx.textBaseline = 'middle';
|
||||||
@@ -55,7 +53,7 @@ module.exports = class SosCommand extends Command {
|
|||||||
let fontSize = 90;
|
let fontSize = 90;
|
||||||
while (ctx.measureText(message).width > 140) {
|
while (ctx.measureText(message).width > 140) {
|
||||||
fontSize--;
|
fontSize--;
|
||||||
ctx.font = `${fontSize}px Noto`;
|
ctx.font = `${fontSize}px Sun Dried`;
|
||||||
}
|
}
|
||||||
ctx.fillText(message.toUpperCase(), 362, 522);
|
ctx.fillText(message.toUpperCase(), 362, 522);
|
||||||
ctx.rotate(-15 * (Math.PI / 180));
|
ctx.rotate(-15 * (Math.PI / 180));
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "122.0.1",
|
"version": "122.0.2",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user