Skip to content

Commit

Permalink
Fix color
Browse files Browse the repository at this point in the history
  • Loading branch information
mezotv committed Feb 1, 2023
1 parent 47487a2 commit 3b55384
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canvabase",
"version": "1.0.1",
"version": "1.0.2",
"description": "An easy to use yet powerful image manipulation library.",
"main": "index.js",
"typings": "./typings/index.d.ts",
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/Welcomer.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Welcomer {
* @returns {Welcomer}
*/

setcolor(color) {
setColor(color) {
if (!color || typeof color !== "string") {
throw new Error("Expected color string instead got " + typeof color);
}
Expand All @@ -109,11 +109,13 @@ class Welcomer {

background = background[Math.floor(Math.random() * background.length)]

const fetchColor = await getColor(background)
console.log(fetchColor)
if(!color) {
const fetchColor = await getColor(background)

if (!color) { color = "#FFFFFF" }
if (isLight(fetchColor)) { color = "#111111" }
}


const canvas = canva.createCanvas(800, 270);
const ctx = canvas.getContext("2d");
Expand Down Expand Up @@ -221,7 +223,7 @@ class Welcomer {
}


// returns the buffer UwU
// returns the buffer Hehe
return canvas.encode("png");
}
}
Expand Down
1 change: 1 addition & 0 deletions test/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const welcomer = new canvabase.Welcomer()
.setTitle("Welcome!")
.addBackground(["https://wallpapercave.com/wp/wp5128415.jpg", "https://wallpapercave.com/wp/wp11735586.jpg"])
.setAvatar("https://cdn.discordapp.com/avatars/347077478726238228/3b77f755fa8e66fd75d1e2d3fb8b1611.png?size=512")
.setColor("#f12")

welcomer.build().then((img) => {
canvabase.write("./test/welcomercard.png", img);
Expand Down
Binary file modified test/welcomercard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3b55384

Please sign in to comment.