New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

canvacard

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvacard - npm Package Compare versions

Comparing version 0.0.1 to 5.1.0

2

deno/README.md
# Canvacard
Coming Soon!!!
¡¡¡Próximamente, en breve, pronto!!!

@@ -35,3 +35,3 @@ // Created and maintained by SrGobi

Util: require("./src/Util"),
Assets: require("@canvacard/assets"),
Assets: require("@canvacord/assets"),
MSX: {

@@ -38,0 +38,0 @@ Brightness: require("./libs/Brightness"),

{
"name": "canvacard",
"version": "0.0.1",
"version": "5.1.0",
"description": "Potente paquete de manipulación de imágenes para principiantes.",

@@ -48,5 +48,5 @@ "main": "index.js",

"captcha-canvas": "^2.2.2",
"discord-canvascard": "github:SrGobi/discord-canvascard",
"discord-canvascard": "github:srgobi/discord-canvascard",
"discord.js-docgen": "github:discordjs/docgen"
}
}
module.exports = (ctx, x, y, height, width, color, stroke = false, lineWidth = 1) => {
if (!ctx) throw new Error("Missing canvas context!");
if (isNaN(x)) throw new Error(`Expected height to be a number, received ${typeof height}!`);
if (isNaN(y)) throw new Error(`Expected width to be a number, received ${typeof width}!`);
if (isNaN(height)) throw new Error(`Expected height to be a number, received ${typeof height}!`);
if (isNaN(width)) throw new Error(`Expected width to be a number, received ${typeof width}!`);
if (!ctx) throw new Error("Falta el contexto del lienzo.");
if (isNaN(x)) throw new Error(`La altura esperada será un número, recibido ${typeof height}!`);
if (isNaN(y)) throw new Error(`Ancho esperado para ser un número, recibido ${typeof width}!`);
if (isNaN(height)) throw new Error(`La altura esperada será un número, recibido ${typeof height}!`);
if (isNaN(width)) throw new Error(`Ancho esperado para ser un número, recibido ${typeof width}!`);
if (!color) color = "#000000";

@@ -8,0 +8,0 @@ stroke = !!stroke;

@@ -13,8 +13,8 @@ const moment = require("moment");

constructor() {
throw new Error(`The ${this.constructor.name} class may not be instantiated!`);
throw new Error(`La clase ${this.constructor.name} no puede ser instanciada`);
}
/**
* Validates hex
* @param {string} hex Hex code to validate
* Valida hexadecimal
* @param {string} hex Código hexadecimal para validar
* @returns {boolean}

@@ -28,4 +28,4 @@ */

/**
* Converts regular timestamp to discord like time
* @param {Date|number} time Timestamp to convert
* Convierte la marca de tiempo regular en discordia como el tiempo
* @param {Date|number} time Marca de tiempo para convertir
* @returns {string}

@@ -41,4 +41,4 @@ */

/**
* Formats time
* @param {number} time Time to format
* Formatea el tiempo
* @param {number} time Hora de formatear
* @returns {string}

@@ -56,5 +56,5 @@ */

/**
* Shorten text.
* @param {string} text Text to shorten
* @param {number} len Max Length
* Acortar el texto.
* @param {string} text Texto para acortar
* @param {number} len Longitud máxima
* @returns {string}

@@ -69,3 +69,3 @@ */

/**
* Converts numbers into units like `1K`, `1M`, `1B` etc.
* Convierte números en unidades como `1K`, `1M`, `1B` etc.
* @param {number|string} num

@@ -80,5 +80,5 @@ * @returns {string}

/**
* Renders text with emoji
* Renderiza texto con emoji
* @param {CanvasRenderingContext2D} ctx CanvasRenderingContext2D
* @param {string} msg Message
* @param {string} msg Mensaje
* @param {number} x X

@@ -93,5 +93,5 @@ * @param {number} y Y

/**
* Returns formatted hex code
* @param {string} hex Hex code to format
* @param {string} alt Alt color
* Devuelve código hexadecimal con formato
* @param {string} hex Código hexadecimal para formatear
* @param {string} alt Color alternativo
* @returns {string}

@@ -109,4 +109,4 @@ */

/**
* Inverts hex color
* @param {string} hex Hex color code to invert
* Invierte el color hexadecimal
* @param {string} hex Código de color hexadecimal para invertir
* @returns {string}

@@ -118,7 +118,7 @@ */

// match hex color
// coincidir con el color hexadecimal
if (hex.length === 3) hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
if (hex.length !== 6) return "#FFFFFF";
// invert colors
// Colores invertidos
const r = (255 - parseInt(hex.slice(0, 2), 16)).toString(16);

@@ -128,3 +128,3 @@ const g = (255 - parseInt(hex.slice(2, 4), 16)).toString(16);

// return new hex
// devolver nuevo hexadecimal
const pad = (txt, length) => {

@@ -141,4 +141,4 @@ length = length || 2;

/**
* Returns acronym
* @param {string} name Name to parse acronym
* Devuelve el acrónimo
* @param {string} name Nombre para analizar el acrónimo
* @returns {string}

@@ -155,7 +155,7 @@ */

/**
* Returns array of lines
* @param {object} params Params
* @param {string} text Text
* Devuelve una matriz de líneas
* @param {object} params Parámetros
* @param {string} text Texto
* @param {CanvasRenderingContext2D} ctx CanvasRenderingContext2D
* @param {number} maxWidth Max width
* @param {number} maxWidth anchura máxima
* @returns {string[]}

@@ -165,4 +165,4 @@ */

if (!text) return [];
if (!ctx) throw new Error("Canvas context was not provided!");
if (!maxWidth) throw new Error("No max-width provided!");
if (!ctx) throw new Error("¡No se proporcionó el contexto del lienzo!");
if (!maxWidth) throw new Error("¡No se proporciona ancho máximo!");
const lines = [];

@@ -169,0 +169,0 @@

@@ -15,3 +15,3 @@ # Canvacard

- Más rápido que canvacard v4 🚀
- ¿Más de ** 50 métodos ** ...? ¡Hurra! 🎉
- ¿Más de **50 métodos** ...? ¡Hurra! 🎉
- Construido sobre un lienzo de nodos y sin tonterías involucradas 🔥

@@ -18,0 +18,0 @@ - Orientado a objetos 💻

@@ -19,3 +19,3 @@ const Trigger = require("../libs/Trigger");

/**
* Canvacard Memes Generator
* Generador De Memes
* @example const Canvacard = require("canvacard");

@@ -22,0 +22,0 @@ *

@@ -7,4 +7,3 @@ const { Base } = require("discord-canvascard");

/**
* Leaver image builder
* @see https://www.discord-canvas.net/functions/goodbye
* Creador de imágenes de abandono
* @example

@@ -25,3 +24,3 @@ * const card = new canvacard.Leaver()

/**
* Title created with Canvacard
* Título creado con Canvacard
* @type {string}

@@ -32,9 +31,9 @@ */

/**
* Text message created with Canvacard
* Mensaje de texto creado con Canvacard
* @type {string}
*/
this.textMessage = "We will miss you!";
this.textMessage = "¡Te extrañaremos!";
/**
* Title color created with canvacard
* Color del título creado con canvacard
* @type {string}

@@ -44,3 +43,3 @@ */

// update default data
// actualizar datos predeterminados
this.__updateData();

@@ -50,3 +49,3 @@ }

/**
* Updates default state
* Actualiza el estado predeterminado
* @returns {void}

@@ -71,5 +70,5 @@ * @private

/**
* Set color
* Establecer color
* @param {"title"|"title-border"|"avatar"|"username"|"username-box"|"hashtag"|"discriminator"|"discriminator-box"|"message"|"message-box"|"member-count"|"background"|"border"} id
* @param {string} color HTML5 color code
* @param {string} color Código de color HTML5
* @returns {Leaver}

@@ -83,4 +82,4 @@ */

/**
* Ser member count
* @param {number|string} memberCount Guild member count
* Recuento de miembros de ser
* @param {number|string} memberCount Recuento de miembros del gremio
* @returns {Leaver}

@@ -94,3 +93,3 @@ */

/**
* Builds welcome image
* Crea una imagen de bienvenida
* @returns {Promise<Buffer>}

@@ -97,0 +96,0 @@ */

/**
* @typedef {object} Plugins
* @property {Function} circle Circle plugin
* @property {Function} convolute Convolute plugin
* @property {Function} rectangle Rectangle plugin
* @property {Function} round Round plugin
* @property {Function} abbrev Abbrev plugin
* @property {Function} renderEmoji Emoji rendering plugin
* @property {Function} circle Complemento de círculo
* @property {Function} convolute Complemento convolute
* @property {Function} rectangle Complemento de rectángulo
* @property {Function} round Complemento redondo
* @property {Function} abbrev Complemento de abreviaturas
* @property {Function} renderEmoji Complemento de renderizado de emoji
*/

@@ -10,0 +10,0 @@ const data = {

@@ -7,58 +7,58 @@ const Canvas = require("canvas");

* @typedef {object} CanvacardRankData
* @property {number} width Rank card width
* @property {number} height Rank card height
* @property {object} background Rank card background data
* @property {"image"|"color"} [background.type="color"] Background type
* @property {string|Buffer} [background.image="#23272A"] Background image (or color)
* @property {object} progressBar Progressbar data
* @property {boolean} [progressBar.rounded=true] If the progressbar should be rounded
* @property {number} [progressBar.x=275.5] Progressbar X
* @property {number} [progressBar.y=183.75] Progressbar Y
* @property {number} [progressBar.height=37.5] Progressbar height
* @property {number} [progressBar.width=596.5] Progressbar width
* @property {object} [progressBar.track] Progressbar track
* @property {string} [progressBar.track.color="#484b4E"] Progressbar track color
* @property {object} [progressBar.bar] Progressbar bar data
* @property {"color"|"gradient"} [progressBar.bar.type="color"] Progressbar bar type
* @property {string|string[]} [progressBar.bar.color="#FFFFFF"] Progressbar bar color
* @property {object} overlay Progressbar overlay
* @property {boolean} [overlay.display=true] If it should display overlay
* @property {number} [overlay.level=0.5] Overlay opacity level
* @property {string} [overlay.color="#333640"] Overlay bg color
* @property {object} avatar Rank card avatar data
* @property {string|Buffer} [avatar.source=null] Avatar source
* @property {number} width Ancho de la tarjeta de rango
* @property {number} height Altura de la tarjeta de rango
* @property {object} background Datos de antecedentes de la tarjeta de rango
* @property {"image"|"color"} [background.type="color"] Tipo de fondo
* @property {string|Buffer} [background.image="#23272A"] Imagen de fondo (o color)
* @property {object} progressBar Datos de la barra de progreso
* @property {boolean} [progressBar.rounded=true] Si la barra de progreso debe redondearse
* @property {number} [progressBar.x=275.5] Barra de progreso X
* @property {number} [progressBar.y=183.75] Barra de progreso Y
* @property {number} [progressBar.height=37.5] Altura de la barra de progreso
* @property {number} [progressBar.width=596.5] Ancho de la barra de progreso
* @property {object} [progressBar.track] Pista de la barra de progreso
* @property {string} [progressBar.track.color="#484b4E"] Color de la pista de la barra de progreso
* @property {object} [progressBar.bar] Datos de la barra de progreso
* @property {"color"|"gradient"} [progressBar.bar.type="color"] Tipo de barra de progreso
* @property {string|string[]} [progressBar.bar.color="#FFFFFF"] Color de la barra de la barra de progreso
* @property {object} overlay Superposición de la barra de progreso
* @property {boolean} [overlay.display=true] Si debería mostrar superposición
* @property {number} [overlay.level=0.5] Nivel de opacidad de superposición
* @property {string} [overlay.color="#333640"] Superposición de color de fondo
* @property {object} avatar Datos de avatar de la tarjeta de rango
* @property {string|Buffer} [avatar.source=null] Fuente de avatar
* @property {number} [avatar.x=70] X
* @property {number} [avatar.y=50] Y
* @property {number} [avatar.height=180] height
* @property {number} [avatar.width=180] width
* @property {object} status Rank card status
* @property {number} [status.width=5] Status width
* @property {"online"|"dnd"|"idle"|"offline"|"streaming"} [status.type] Status type
* @property {string} [status.color="#43B581"] Status color
* @property {boolean} [status.circle=false] Circualr status?
* @property {object} rank Rank card rank data
* @property {boolean} [rank.display=true] If it should display rank
* @property {number} [rank.data=1] The Rank
* @property {string} [rank.textColor="#FFFFFF"] Rank text color
* @property {string} [rank.color="#F3F3F3"] Rank color
* @property {string} [rank.displayText="RANK"] Rank display text
* @property {object} level Rank card level data
* @property {boolean} [level.display=true] If it should display level
* @property {number} [level.data=1] The level
* @property {string} [level.textColor="#FFFFFF"] level text color
* @property {string} [level.color="#F3F3F3"] level color
* @property {string} [level.displayText="LEVEL"] level display text
* @property {object} currentXP Rank card current xp
* @property {number} [currentXP.data=0] Current xp
* @property {string} [currentXP.color="#FFFFFF"] Rank card current xp color
* @property {object} requiredXP Rank card required xp
* @property {number} [requiredXP.data=0] required xp
* @property {string} [requiredXP.color="#FFFFFF"] Rank card required xp color
* @property {object} discriminator Rank card discriminator
* @property {number|string} [discriminator.discrim=null] The discriminator
* @property {string} [discriminator.color="rgba(255, 255, 255, 0.4)"] Rank card discriminator color
* @property {object} username Username Data
* @property {string} [username.name=null] Rank card username
* @property {string} [username.color="#FFFFFF"] Rank card username color
* @property {boolean} [renderEmojis=false] If it should render emojis
* @property {number} [avatar.height=180] altura
* @property {number} [avatar.width=180] ancho
* @property {object} status Estado de la tarjeta de rango
* @property {number} [status.width=5] Ancho de estado
* @property {"online"|"dnd"|"idle"|"offline"|"streaming"} [status.type] Tipo de estado
* @property {string} [status.color="#43B581"] Color de estado
* @property {boolean} [status.circle=false] ¿Estado circular?
* @property {object} rank Datos de rango de la tarjeta de clasificación
* @property {boolean} [rank.display=true] Si debe mostrar rango
* @property {number} [rank.data=1] El rango
* @property {string} [rank.textColor="#FFFFFF"] Rango de color del texto
* @property {string} [rank.color="#F3F3F3"] Color de rango
* @property {string} [rank.displayText="RANK"] Texto de visualización de rango
* @property {object} level Datos de nivel de tarjeta de rango
* @property {boolean} [level.display=true] Si debería mostrar el nivel
* @property {number} [level.data=1] El nivel
* @property {string} [level.textColor="#FFFFFF"] color de texto de nivel
* @property {string} [level.color="#F3F3F3"] color de nivel
* @property {string} [level.displayText="LEVEL"] texto de visualización de nivel
* @property {object} currentXP Tarjeta de rango xp actual
* @property {number} [currentXP.data=0] XP actual
* @property {string} [currentXP.color="#FFFFFF"] Carta de rango color xp actual
* @property {object} requiredXP Tarjeta de rango requerida xp
* @property {number} [requiredXP.data=0] requerido xp
* @property {string} [requiredXP.color="#FFFFFF"] Se requiere tarjeta de rango xp color
* @property {object} discriminator Discriminador de cartas de rango
* @property {number|string} [discriminator.discrim=null] El discriminador
* @property {string} [discriminator.color="rgba(255, 255, 255, 0.4)"] Color del discriminador de la tarjeta de rango
* @property {object} username Datos de nombre de usuario
* @property {string} [username.name=null] Nombre de usuario de la tarjeta de clasificación
* @property {string} [username.color="#FFFFFF"] Color de nombre de usuario de la tarjeta de rango
* @property {boolean} [renderEmojis=false] Si debería renderizar emojis
*/

@@ -69,3 +69,3 @@

/**
* Creates Rank card
* Crea una carta de rango
* @example

@@ -89,3 +89,3 @@ * const rank = new canvacard.Rank()

/**
* Rank card data
* Datos de la tarjeta de clasificación
* @type {CanvacardRankData}

@@ -165,3 +165,3 @@ */

// Load default fonts
// Cargar fuentes predeterminadas
this.registerFonts();

@@ -171,4 +171,4 @@ }

/**
* Loads font
* @param {any[]} fontArray Font array
* Fuente Loads
* @param {any[]} fontArray Matriz de fuentes
* @returns {Rank}

@@ -179,3 +179,3 @@ */

setTimeout(() => {
// default fonts
// fuentes predeterminadas
Canvas.registerFont(assets("FONT").MANROPE_BOLD, {

@@ -203,4 +203,4 @@ family: "Manrope",

/**
* If it should render username with emojis (if any)
* @param {boolean} [apply=false] Set it to `true` to render emojis.
* Si debe representar el nombre de usuario con emojis (si corresponde)
* @param {boolean} [apply=false] Configúrelo en "verdadero" para renderizar emojis.
* @returns {Rank}

@@ -214,9 +214,9 @@ */

/**
* Set username
* @param {string} name Username
* @param {string} color Username color
* Establecer nombre de usuario
* @param {string} name Nombre de usuario
* @param {string} color Color del nombre de usuario
* @returns {Rank}
*/
setUsername(name, color = "#FFFFFF") {
if (typeof name !== "string") throw new Error(`Expected username to be a string, received ${typeof name}!`);
if (typeof name !== "string") throw new Error(`Se esperaba que el nombre de usuario fuera una cadena, recibido ${typeof name}!`);
this.data.username.name = name;

@@ -228,5 +228,5 @@ this.data.username.color = color && typeof color === "string" ? color : "#FFFFFF";

/**
* Set discriminator
* @param {string|number} discriminator User discriminator
* @param {string} color Discriminator color
* Establecer discriminador
* @param {string|number} discriminator Discriminador de usuario
* @param {string} color Color discriminador
* @returns {Rank}

@@ -241,6 +241,6 @@ */

/**
* Set progressbar style
* @param {string|string[]} color Progressbar Color
* @param {"COLOR"|"GRADIENT"} [fillType] Progressbar type
* @param {boolean} [rounded=true] If progressbar should have rounded edges
* Establecer el estilo de la barra de progreso
* @param {string|string[]} color Color de la barra de progreso
* @param {"COLOR"|"GRADIENT"} [fillType] Tipo de barra de progreso
* @param {boolean} [rounded=true] Si la barra de progreso debe tener bordes redondeados
* @returns {Rank}

@@ -252,3 +252,3 @@ */

case "COLOR":
if (typeof color !== "string") throw new Error(`Color type must be a string, received ${typeof color}!`);
if (typeof color !== "string") throw new Error(`El tipo de color debe ser una cadena, recibido ${typeof color}!`);
this.data.progressBar.bar.color = color;

@@ -259,3 +259,3 @@ this.data.progressBar.bar.type = "color";

case "GRADIENT":
if (!Array.isArray(color)) throw new Error(`Color type must be Array, received ${typeof color}!`);
if (!Array.isArray(color)) throw new Error(`El tipo de color debe ser Matriz, recibido ${typeof color}!`);
this.data.progressBar.bar.color = color.slice(0, 2);

@@ -266,3 +266,3 @@ this.data.progressBar.bar.type = "gradient";

default:
throw new Error(`Unsupported progressbar type "${type}"!`);
throw new Error(`Tipo de barra de progreso no admitido "${type}"!`);
}

@@ -275,8 +275,8 @@

/**
* Set progressbar track
* @param {string} color Track color
* Establecer pista de la barra de progreso
* @param {string} color Color de la pista
* @returns {Rank}
*/
setProgressBarTrack(color) {
if (typeof color !== "string") throw new Error(`Color type must be a string, received "${typeof color}"!`);
if (typeof color !== "string") throw new Error(`El tipo de color debe ser una cadena, recibido "${typeof color}"!`);
this.data.progressBar.track.color = color;

@@ -288,10 +288,10 @@

/**
* Set card overlay
* @param {string} color Overlay color
* @param {number} [level=0.5] Opacity level
* @param {boolean} [display=true] IF it should display overlay
* Establecer superposición de tarjetas
* @param {string} color Color de superposición
* @param {number} [level=0.5] Nivel de opacidad
* @param {boolean} [display=true] SI debería mostrar superposición
* @returns {Rank}
*/
setOverlay(color, level = 0.5, display = true) {
if (typeof color !== "string") throw new Error(`Color type must be a string, received "${typeof color}"!`);
if (typeof color !== "string") throw new Error(`El tipo de color debe ser una cadena, recibido "${typeof color}"!`);
this.data.overlay.color = color;

@@ -304,4 +304,4 @@ this.data.overlay.display = !!display;

/**
* Set required xp
* @param {number} data Required xp
* Establecer xp requerido
* @param {number} data Requerido xp
* @param {string} color Color

@@ -311,3 +311,3 @@ * @returns {Rank}

setRequiredXP(data, color = "#FFFFFF") {
if (typeof data !== "number") throw new Error(`Required xp data type must be a number, received ${typeof data}!`);
if (typeof data !== "number") throw new Error(`El tipo de datos xp requerido debe ser un número, recibido ${typeof data}!`);
this.data.requiredXP.data = data;

@@ -319,4 +319,4 @@ this.data.requiredXP.color = color && typeof color === "string" ? color : "#FFFFFF";

/**
* Set current xp
* @param {number} data Current xp
* Establecer xp actual
* @param {number} data XP actual
* @param {string} color Color

@@ -326,3 +326,3 @@ * @returns {Rank}

setCurrentXP(data, color = "#FFFFFF") {
if (typeof data !== "number") throw new Error(`Current xp data type must be a number, received ${typeof data}!`);
if (typeof data !== "number") throw new Error(`El tipo de datos xp actual debe ser un número, recibido ${typeof data}!`);
this.data.currentXP.data = data;

@@ -334,10 +334,10 @@ this.data.currentXP.color = color && typeof color === "string" ? color : "#FFFFFF";

/**
* Set Rank
* @param {number} data Current Rank
* @param {string} text Display text
* @param {boolean} [display=true] If it should display rank
* Establecer rango
* @param {number} data Posición actual
* @param {string} text Mostrar texto
* @param {boolean} [display=true] Si debe mostrar rango
* @returns {Rank}
*/
setRank(data, text = "RANK", display = true) {
if (typeof data !== "number") throw new Error(`Level data must be a number, received ${typeof data}!`);
if (typeof data !== "number") throw new Error(`Los datos de nivel deben ser un número, recibido ${typeof data}!`);
this.data.rank.data = data;

@@ -352,5 +352,5 @@ this.data.rank.display = !!display;

/**
* Set rank display color
* @param {string} text text color
* @param {string} number Number color
* Establecer color de visualización de rango
* @param {string} text color de texto
* @param {string} number Color del número
* @returns {Rank}

@@ -367,5 +367,5 @@ */

/**
* Set level color
* @param {string} text text color
* @param {string} number number color
* Establecer color de nivel
* @param {string} text color de texto
* @param {string} number color del número
* @returns {Rank}

@@ -382,10 +382,10 @@ */

/**
* Set Level
* @param {number} data Current Level
* @param {string} text Display text
* @param {boolean} [display=true] If it should display level
* Establecer nivel
* @param {number} data Nivel actual
* @param {string} text Mostrar texto
* @param {boolean} [display=true] Si debería mostrar el nivel
* @returns {Rank}
*/
setLevel(data, text = "LEVEL", display = true) {
if (typeof data !== "number") throw new Error(`Level data must be a number, received ${typeof data}!`);
if (typeof data !== "number") throw new Error(`Los datos de nivel deben ser un número, recibido ${typeof data}!`);
this.data.level.data = data;

@@ -400,8 +400,8 @@ this.data.level.display = !!display;

/**
* Set custom status color
* @param {string} color Color to set
* Establecer color de estado personalizado
* @param {string} color Color para establecer
* @returns {Rank}
*/
setCustomStatusColor(color) {
if (!color || typeof color !== "string") throw new Error("Invalid color!");
if (!color || typeof color !== "string") throw new Error("¡Color no válido!");
this.data.status.color = color;

@@ -412,6 +412,6 @@ return this;

/**
* Set status
* @param {"online"|"idle"|"dnd"|"offline"|"streaming"} status User status
* @param {boolean} circle If status icon should be circular.
* @param {number|boolean} width Status width
* Establecer estado
* @param {"online"|"idle"|"dnd"|"offline"|"streaming"} status Estatus de usuario
* @param {boolean} circle Si el icono de estado debe ser circular.
* @param {number|boolean} width Ancho de estado
* @returns {Rank}

@@ -442,3 +442,3 @@ */

default:
throw new Error(`Invalid status "${status}"`);
throw new Error(`Estado inválido "${status}"`);
}

@@ -454,9 +454,9 @@

/**
* Set background image/color
* @param {"COLOR"|"IMAGE"} type Background type
* @param {string|Buffer} [data] Background color or image
* Establecer imagen / color de fondo
* @param {"COLOR"|"IMAGE"} type Tipo de fondo
* @param {string|Buffer} [data] Color o imagen de fondo
* @returns {Rank}
*/
setBackground(type, data) {
if (!data) throw new Error("Missing field : data");
if (!data) throw new Error("Falta campo: datos");
switch(type) {

@@ -472,3 +472,3 @@ case "COLOR":

default:
throw new Error(`Unsupported background type "${type}"`);
throw new Error(`Tipo de fondo no admitido "${type}"`);
}

@@ -480,8 +480,8 @@

/**
* User avatar
* @param {string|Buffer} data Avatar data
* Avatar de usuario
* @param {string|Buffer} data Datos de avatar
* @returns {Rank}
*/
setAvatar(data) {
if (!data) throw new Error(`Invalid avatar type "${typeof data}"!`);
if (!data) throw new Error(`Tipo de avatar no válido "${typeof data}"!`);
this.data.avatar.source = data;

@@ -492,13 +492,13 @@ return this;

/**
* Builds rank card
* @param {object} ops Fonts
* @param {string} [ops.fontX="Manrope"] Bold font family
* @param {string} [ops.fontY="Manrope"] Regular font family
* Construye carta de rango
* @param {object} ops Fuentes
* @param {string} [ops.fontX="Manrope"] Familia tipográfica Bold
* @param {string} [ops.fontY="Manrope"] Familia tipográfica regular
* @returns {Promise<Buffer>}
*/
async build(ops = { fontX: "Manrope", fontY: "Manrope" }) {
if (typeof this.data.currentXP.data !== "number") throw new Error(`Expected currentXP to be a number, received ${typeof this.data.currentXP.data}!`);
if (typeof this.data.requiredXP.data !== "number") throw new Error(`Expected requiredXP to be a number, received ${typeof this.data.requiredXP.data}!`);
if (!this.data.avatar.source) throw new Error("Avatar source not found!");
if (!this.data.username.name) throw new Error("Missing username");
if (typeof this.data.currentXP.data !== "number") throw new Error(`Se esperaba que currentXP sea un número recibido ${typeof this.data.currentXP.data}!`);
if (typeof this.data.requiredXP.data !== "number") throw new Error(`Se esperaba que requiredXP sea un número recibido ${typeof this.data.requiredXP.data}!`);
if (!this.data.avatar.source) throw new Error("¡No se encontró la fuente del avatar!");
if (!this.data.username.name) throw new Error("Falta el nombre de usuario");

@@ -509,7 +509,7 @@ let bg = null;

// create canvas instance
// crear instancia de lienzo
const canvas = Canvas.createCanvas(this.data.width, this.data.height);
const ctx = canvas.getContext("2d");
// create background
// crear fondo
if (!!bg) {

@@ -522,3 +522,3 @@ ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);

// add overlay
// agregar superposición
if (!!this.data.overlay.display) {

@@ -530,6 +530,6 @@ ctx.globalAlpha = this.data.overlay.level || 1;

// reset transparency
// restablecer la transparencia
ctx.globalAlpha = 1;
// draw username
// dibujar nombre de usuario
ctx.font = `bold 36px ${ops.fontX}`;

@@ -540,7 +540,7 @@ ctx.fillStyle = this.data.username.color;

// apply username
// aplicar nombre de usuario
!this.data.renderEmojis ? ctx.fillText(`${name}`, 257 + 18.5, 164) : await Util.renderEmoji(ctx, name, 257 + 18.5, 164);
// draw discriminator
if (!this.data.discriminator.discrim) throw new Error("Missing discriminator!");
// dibujar discriminador
if (!this.data.discriminator.discrim) throw new Error("¡Falta discriminador!");
const discrim = `${this.data.discriminator.discrim}`;

@@ -554,3 +554,3 @@ if (discrim) {

// fill level
// nivel de llenado
if (this.data.level.display && !isNaN(this.data.level.data)) {

@@ -567,3 +567,3 @@ ctx.font = `bold 36px ${ops.fontX}`;

// fill rank
// llenar el rango
if (this.data.rank.display && !isNaN(this.data.rank.data)) {

@@ -580,3 +580,3 @@ ctx.font = `bold 36px ${ops.fontX}`;

// show progress
// mostrar progreso
ctx.font = `bold 30px ${ops.fontX}`;

@@ -590,3 +590,3 @@ ctx.fillStyle = this.data.requiredXP.color;

// draw progressbar
// dibujar barra de progreso
ctx.beginPath();

@@ -603,3 +603,3 @@ if (!!this.data.progressBar.rounded) {

ctx.beginPath();
// apply color
// aplicar color
if (this.data.progressBar.bar.type === "gradient") {

@@ -615,3 +615,3 @@ let gradientContext = ctx.createRadialGradient(this._calculateProgress, 0, 500, 0);

// progress bar
// barra de progreso
ctx.arc(257 + 18.5, 147.5 + 18.5 + 36.25, 18.5, 1.5 * Math.PI, 0.5 * Math.PI, true);

@@ -624,7 +624,7 @@ ctx.fill();

// progress bar
// barra de progreso
ctx.fillStyle = this.data.progressBar.bar.color;
ctx.fillRect(this.data.progressBar.x, this.data.progressBar.y, this._calculateProgress, this.data.progressBar.height);
// outline
// contorno
ctx.beginPath();

@@ -638,3 +638,3 @@ ctx.strokeStyle = this.data.progressBar.track.color;

// circle
// circulo
ctx.beginPath();

@@ -645,7 +645,7 @@ ctx.arc(125 + 10, 125 + 20, 100, 0, Math.PI * 2, true);

// draw avatar
// dibujar avatar
ctx.drawImage(avatar, 35, 45, this.data.avatar.width + 20, this.data.avatar.height + 20);
ctx.restore();
// draw status
// estado del sorteo
if (!!this.data.status.circle) {

@@ -669,3 +669,3 @@ ctx.beginPath();

/**
* Calculates progress
* Calcula el progreso
* @type {number}

@@ -672,0 +672,0 @@ * @private

@@ -6,3 +6,3 @@ const Canvas = require("canvas");

/**
* Spotify presence card builder
* Creador de tarjetas de presencia de Spotify
*/

@@ -12,3 +12,3 @@ class Spotify {

/**
* Creates spotify presence card
* Crea una tarjeta de presencia de Spotify
* @example

@@ -31,3 +31,3 @@ * const card = new canvacard.Spotify()

/**
* Song title
* Título de la canción
* @type {string}

@@ -44,3 +44,3 @@ */

/**
* Song artist
* Artista de la canción
* @type {string}

@@ -51,3 +51,3 @@ */

/**
* Spotify album name
* Nombre del álbum de Spotify
* @type {string}

@@ -58,3 +58,3 @@ */

/**
* Discord presence started timestamp
* Marca de tiempo de inicio de presencia de discordia
* @type {number}

@@ -65,3 +65,3 @@ */

/**
* Discord presence ending timestamp
* Marca de tiempo de finalización de presencia de discordia
* @type {number}

@@ -73,8 +73,8 @@ */

* @typedef {object} SpotifyDataBG
* @property {number} type Background type
* @property {string|Buffer} data Background data
* @property {number} type Tipo de fondo
* @property {string|Buffer} data Datos de fondo
*/
/**
* Background
* Fondo
* @type {SpotifyDataBG}

@@ -89,8 +89,8 @@ */

* @typedef {object} SpotifyProgressBarData
* @property {string} bgColor Progressbar bg color
* @property {string} color Progressbar bg color
* @property {string} bgColor Barra de progreso bg color
* @property {string} color Barra de progreso bg color
*/
/**
* Progressbar details
* Detalles de la barra de progreso
* @type {SpotifyProgressBarData}

@@ -107,3 +107,3 @@ */

/**
* Register fonts
* Registrar fuentes
* @returns {void}

@@ -130,5 +130,5 @@ * @ignore

/**
* Set progressbar details
* @param {"TRACK"|"BAR"} type Progressbar type
* @param {string} color Color to set
* Establecer detalles de la barra de progreso
* @param {"TRACK"|"BAR"} type Tipo de barra de progreso
* @param {string} color Color para establecer
* @returns {Spotify}

@@ -146,3 +146,3 @@ */

default:
throw new Error(`Invalid progressbar type "${type}"!`);
throw new Error(`Tipo de barra de progreso no válido "${type}"!`);
}

@@ -154,8 +154,8 @@

/**
* Set title
* @param {string} title Title to set
* Establecer título
* @param {string} title Título para establecer
* @returns {Spotify}
*/
setTitle(title) {
if (!title || typeof title !== "string") throw new Error(`Expected title, received ${typeof title}!`);
if (!title || typeof title !== "string") throw new Error(`Título esperado, recibido ${typeof title}!`);
this.title = title;

@@ -166,8 +166,8 @@ return this;

/**
* Set image
* @param {string|Buffer|Canvas.Image} source Image source
* Establecer imagen
* @param {string|Buffer|Canvas.Image} source Fuente de imagen
* @returns {Spotify}
*/
setImage(source) {
if (!source) throw new Error(`Expected image source, received ${typeof title}!`);
if (!source) throw new Error(`Fuente de imagen esperada, recibida ${typeof title}!`);
this.image = source;

@@ -178,8 +178,8 @@ return this;

/**
* Set artist name
* @param {string} name Artist name
* Establecer nombre de artista
* @param {string} name Nombre del artista
* @returns {Spotify}
*/
setAuthor(name) {
if (!name || typeof name !== "string") throw new Error(`Expected artist name, received ${typeof name}!`);
if (!name || typeof name !== "string") throw new Error(`Nombre esperado del artista, recibido ${typeof name}!`);
this.artist = name;

@@ -190,8 +190,8 @@ return this;

/**
* Set album name
* @param {string} name Album name
* Establecer el nombre del álbum
* @param {string} name Nombre del álbum
* @returns {Spotify}
*/
setAlbum(name) {
if (!name || typeof name !== "string") throw new Error(`Expected album name, received ${typeof name}!`);
if (!name || typeof name !== "string") throw new Error(`Nombre del álbum esperado, recibido ${typeof name}!`);
this.album = name;

@@ -202,8 +202,8 @@ return this;

/**
* Set start timestamp
* @param {Date|number} time Timestamp
* Establecer marca de tiempo de inicio
* @param {Date|number} time Marca de tiempo
* @returns {Spotify}
*/
setStartTimestamp(time) {
if (!time) throw new Error(`Expected timestamp, received ${typeof time}!`);
if (!time) throw new Error(`Marca de tiempo esperada, recibida ${typeof time}!`);
if (time instanceof Date) time = time.getTime();

@@ -215,8 +215,8 @@ this.start = time;

/**
* Set end timestamp
* @param {Date|number} time Timestamp
* Establecer marca de tiempo de finalización
* @param {Date|number} time Marca de tiempo
* @returns {Spotify}
*/
setEndTimestamp(time) {
if (!time) throw new Error(`Expected timestamp, received ${typeof time}!`);
if (!time) throw new Error(`Marca de tiempo esperada, recibida ${typeof time}!`);
if (time instanceof Date) time = time.getTime();

@@ -228,5 +228,5 @@ this.end = time;

/**
* Set background
* @param {"COLOR"|"IMAGE"} type Background type
* @param {string|Buffer|Canvas.Image} data Background data
* Definir fondo
* @param {"COLOR"|"IMAGE"} type Tipo de fondo
* @param {string|Buffer|Canvas.Image} data Datos de fondo
* @returns {Spotify}

@@ -241,3 +241,3 @@ */

case "IMAGE":
if (!data) throw new Error("Missing background data!");
if (!data) throw new Error("¡Faltan datos de fondo!");
this.background.type = 1;

@@ -247,3 +247,3 @@ this.background.data = data;

default:
throw new Error(`Invalid background type "${type}"!`);
throw new Error(`Tipo de fondo no válido "${type}"!`);
}

@@ -255,10 +255,10 @@

/**
* This function converts raw data into spotify presence card.
* Esta función convierte los datos sin procesar en una tarjeta de presencia de Spotify.
* @returns {Promise<Buffer>}
*/
async build() {
if (!this.title) throw new Error('Missing "title" in options.');
if (!this.artist) throw new Error('Missing "artist" in options.');
if (!this.start) throw new Error('Missing "start" in options.');
if (!this.end) throw new Error('Missing "end" in options.');
if (!this.title) throw new Error('Falta el "título" en las opciones.');
if (!this.artist) throw new Error('Falta "artista" en las opciones.');
if (!this.start) throw new Error('Falta "inicio" en las opciones.');
if (!this.end) throw new Error('Falta "final" en las opciones.');

@@ -273,3 +273,3 @@ const total = this.end - this.start;

// background
// fondo
ctx.beginPath();

@@ -285,7 +285,7 @@ if (this.background.type === 0) {

// draw image
// dibujar imagen
const img = await Canvas.loadImage(this.image);
ctx.drawImage(img, 30, 15, 120, 120);
// draw songname
// dibujar el nombre de la canción
ctx.fillStyle = "#FFFFFF";

@@ -295,15 +295,15 @@ ctx.font = "bold 20px Manrope";

// draw artist name
// dibujar el nombre del artista
ctx.fillStyle = "#F1F1F1";
ctx.font = "14px Manrope";
await Util.renderEmoji(ctx, `by ${Util.shorten(this.artist, 40)}`, 170, 70);
await Util.renderEmoji(ctx, `por ${Util.shorten(this.artist, 40)}`, 170, 70);
// add album
// agregar álbum
if (this.album && typeof this.album === "string") {
ctx.fillStyle = "#F1F1F1";
ctx.font = "14px Manrope";
await Util.renderEmoji(ctx, `on ${Util.shorten(this.album, 40)}`, 170, 90);
await Util.renderEmoji(ctx, `en ${Util.shorten(this.album, 40)}`, 170, 90);
}
// ending point
// punto final
ctx.fillStyle = "#B3B3B3";

@@ -313,3 +313,3 @@ ctx.font = "14px Manrope";

// progress
// Progreso
ctx.fillStyle = "#B3B3B3";

@@ -319,3 +319,3 @@ ctx.font = "14px Manrope";

// progressbar track
// pista de la barra de progreso
ctx.rect(170, 170, 300, 4);

@@ -325,7 +325,7 @@ ctx.fillStyle = "#E8E8E8";

// progressbar
// barra de progreso
ctx.fillStyle = "#1DB954";
ctx.fillRect(170, 110, this.__calculateProgress(progress, total), 4);
// return
// regreso
return canvas.toBuffer();

@@ -335,3 +335,3 @@ }

/**
* Returns progress
* Progreso de devoluciones
* @type {number}

@@ -338,0 +338,0 @@ * @private

@@ -14,8 +14,8 @@ const moment = require("moment");

constructor() {
throw new Error(`The ${this.constructor.name} class may not be instantiated!`);
throw new Error(`La clase ${this.constructor.name} no puede ser instanciada!`);
}
/**
* Validates hex
* @param {string} hex Hex code to validate
* Valida hexadecimal
* @param {string} hex Código hexadecimal para validar
* @returns {boolean}

@@ -29,4 +29,4 @@ */

/**
* Converts regular timestamp to discord like time
* @param {Date|number} time Timestamp to convert
* Convierte la marca de tiempo regular en discordia como el tiempo
* @param {Date|number} time Marca de tiempo para convertir
* @returns {string}

@@ -42,4 +42,4 @@ */

/**
* Formats time
* @param {number} time Time to format
* Formatea el tiempo
* @param {number} time Hora de formatear
* @returns {string}

@@ -57,5 +57,5 @@ */

/**
* Shorten text.
* @param {string} text Text to shorten
* @param {number} len Max Length
* Acortar el texto.
* @param {string} text Texto para acortar
* @param {number} len Longitud máxima
* @returns {string}

@@ -70,3 +70,3 @@ */

/**
* Converts numbers into units like `1K`, `1M`, `1B` etc.
* Convierte números en unidades como `1K`, `1M`, `1B` etc.
* @param {number|string} num

@@ -81,5 +81,5 @@ * @returns {string}

/**
* Renders text with emoji
* Renderiza texto con emoji
* @param {CanvasRenderingContext2D} ctx CanvasRenderingContext2D
* @param {string} msg Message
* @param {string} msg Mensaje
* @param {number} x X

@@ -94,4 +94,4 @@ * @param {number} y Y

/**
* Returns formatted hex code
* @param {string} hex Hex code to format
* Devuelve código hexadecimal con formato
* @param {string} hex Código hexadecimal para formatear
* @param {string} alt Alt color

@@ -110,4 +110,4 @@ * @returns {string}

/**
* Inverts hex color
* @param {string} hex Hex color code to invert
* Invierte el color hexadecimal
* @param {string} hex Código de color hexadecimal para invertir
* @returns {string}

@@ -119,7 +119,7 @@ */

// match hex color
// coincidir con el color hexadecimal
if (hex.length === 3) hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
if (hex.length !== 6) return "#FFFFFF";
// invert colors
// Colores invertidos
const r = (255 - parseInt(hex.slice(0, 2), 16)).toString(16);

@@ -129,3 +129,3 @@ const g = (255 - parseInt(hex.slice(2, 4), 16)).toString(16);

// return new hex
// devolver nuevo hexadecimal
const pad = (txt, length) => {

@@ -142,4 +142,4 @@ length = length || 2;

/**
* Returns acronym
* @param {string} name Name to parse acronym
* Devuelve el acrónimo
* @param {string} name Nombre para analizar el acrónimo
* @returns {string}

@@ -156,7 +156,7 @@ */

/**
* Returns array of lines
* @param {object} params Params
* @param {string} text Text
* Devuelve una matriz de líneas
* @param {object} params Parámetros
* @param {string} text Texto
* @param {CanvasRenderingContext2D} ctx CanvasRenderingContext2D
* @param {number} maxWidth Max width
* @param {number} maxWidth Anchura máxima
* @returns {string[]}

@@ -166,4 +166,4 @@ */

if (!text) return [];
if (!ctx) throw new Error("Canvas context was not provided!");
if (!maxWidth) throw new Error("No max-width provided!");
if (!ctx) throw new Error("¡No se proporcionó el contexto del lienzo!");
if (!maxWidth) throw new Error("¡No se proporciona ancho máximo!");
const lines = [];

@@ -170,0 +170,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc