Skip to content

Commit

Permalink
fix rank card gradient
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Sep 21, 2022
1 parent 7e181cb commit ac7628f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Rank.js
Expand Up @@ -557,7 +557,7 @@ class Rank {
ctx.beginPath();
// apply color
if (this.data.progressBar.bar.type === "gradient") {
let gradientContext = ctx.createRadialGradient(this._calculateProgress, 0, 500, 0);
let gradientContext = ctx.createRadialGradient(this._calculateProgress, 0, 500, 0, 0, 0);
this.data.progressBar.bar.color.forEach((color, index) => {
gradientContext.addColorStop(index, color);
});
Expand Down
Binary file added test/card.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion test/index.js
@@ -1,3 +1,22 @@
const canvacord = require("../index");
const img = "https://cdn.discordapp.com/embed/avatars/0.png";

console.log(canvacord);
const userData = {
xp: 500,
requiredXP: 845
};

const rank = new canvacord.Rank()
.setAvatar(img)
.setCurrentXP(userData.xp)
.setRequiredXP(userData.requiredXP)
.setStatus("dnd")
.setProgressBar(["#14C49E", "#FF0000"], "GRADIENT", true)
.setProgressBarTrack("#FFFFFF")
.setUsername("Snowflake")
.setDiscriminator("0007");

rank.build()
.then(data => {
canvacord.write(data, "./card.png");
});

0 comments on commit ac7628f

Please sign in to comment.