MinequackCPP/classes/colors.cpp
2022-04-07 16:50:51 +03:00

25 lines
No EOL
591 B
C++

#include "../headers/colors.h"
int COLORS::hexToDec(char num[]) {
int len = strlen(num);
int base = 1;
int temp = 0;
for (int i=len-1; i>=0; i--) {
if (num[i]>='0' && num[i]<='9') {
temp += (num[i] - 48)*base;
base = base * 16;
}
else if (num[i]>='A' && num[i]<='F') {
temp += (num[i] - 55)*base;
base = base*16;
}
}
return temp;
}
// int COLORS::toRGB(char hexcode[]) {
// std::vector rgb;
// for(int i = 0; i < 3; i++) {
// rgb.push_back(hexToDec(hexcode[i*2] + hexcode[i*2+1]));
// }
// }