Skip to content

Commit

Permalink
only support alpha by providing rgba() css string
Browse files Browse the repository at this point in the history
  • Loading branch information
ericente committed Mar 5, 2022
1 parent 56a0277 commit 373e166
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions packages/gradients/src/GradientFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,11 @@ function cssColor(color: number | string) {
}
let string = color.toString(16);

if(string.length === 3){
string = `#${string[0]}${string[0]}${string[1]}${string[1]}${string[2]}${string[2]}`;
}
else if(string.length === 8){
string = `rgba(${parseInt(string.substring(0, 2), 16)}, ${parseInt(string.substring(2, 4), 16)}, ${parseInt(string.substring(4, 6), 16)}, ${parseInt(string.substring(6), 16)/255})`;
}
else{
while (string.length < 6) {
string = `0${string}`;
}
string = `#${string}`;
while (string.length < 6) {
string = `0${string}`;
}

return string;
return `#${string}`;
}

const tempSourceFrame = new Rectangle();
Expand Down

0 comments on commit 373e166

Please sign in to comment.