-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why the convert color result is #RRGGBBAA? #3
Comments
This is strange. Could you help me finding the bug in the library (https://github.com/seanghay/vector-drawable-svg/blob/master/src/vector-drawable-svg.js) and make a pull request and I will merge asap? The source is quite small and simple. |
Hey, I had a look at the convertHexColor method and noticed that it takes in either a 4 digit or an 8 digit hex code value and modifies it by taking the alpha values from the front and adding them to the end. This is why wejoy's color values went from #FFF64545 to #F64545FF or #FFCC1D1D to #CC1D1DFF. The program works as intended, but the outputted hex code may not be the same on different environments when they convert the 8 digit code into a 6 digit hex code. From what I've seen, they remove the AA values at the end of the 8 digit code. In the instance of the first color, the original unconverted value would go from FFF64545 to FFF645 (yellow) and the converted value F64545FF to F64545 (red). I think the solution might be to change the method such that it converts the 8 digit hex code to a 6 digit one by removing the alpha values all together. |
function convertHexColor(argb) {
const digits = argb.replace(/^#/, '');
if (digits.length !== 4 && digits.length !== 8) {
return argb;
}
let red, green, blue, alpha;
if (digits.length === 4) {
alpha = digits[0];
red = digits[1];
green = digits[2];
blue = digits[3];
} else {
alpha = digits.substr(0, 2);
red = digits.substr(2, 2);
green = digits.substr(4, 2);
blue = digits.substr(6, 2);
}
return '#' + red + green + blue + alpha;
} Indeed, the return string is '#' + red + green + blue + alpha; |
I went there from floo.app, I am not familiar with next.js, I was actually in converting my android app to harmonyos arkui platform, just find this tool to convert vector drawable back to the svg, it's a very useful tool to me, btw. It seems Shehryar has located problem. |
For example, this one,
The gradient colors were converted to #CC1D1DFF and #F64545FF ...
It seems have some display problem in my develop enviroument, but ok on the chrome, it that some kind of SVG version reason?
The text was updated successfully, but these errors were encountered: