Changed colors from string to uint32.

This commit is contained in:
tastytea 2018-12-25 22:17:17 +01:00
parent 85c47a45fd
commit aaece0eabc
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 8 additions and 21 deletions

View File

@ -27,7 +27,7 @@ int main(int argc, char *argv[])
return 1;
}
Identiconpp identicon(5, 5, "ffffffff", {"000000ff", "000000"});
Identiconpp identicon(5, 5, 0xffffffff, { 0x000000ff, 0x000000 });
return 0;
}

View File

@ -20,26 +20,12 @@
#include "debug.hpp"
Identiconpp::Identiconpp(const uint8_t rows, const uint8_t columns,
const string &background,
const vector<string> &foreground)
const uint32_t background,
const vector<uint32_t> &foreground)
: _rows(rows)
, _columns(columns)
, _background(background)
, _foreground(foreground)
{
// TODO: Check rows and columns
if (_background.size() != 8)
{
throw std::invalid_argument("Background color has the wrong format: " +
_background);
}
for (const string &color : _foreground)
{
if (color.size() != 8)
{
throw std::invalid_argument("Foreground color has the wrong format: " +
color);
}
}
}

View File

@ -19,6 +19,7 @@
#include <vector>
using std::uint8_t;
using std::uint32_t;
using std::string;
using std::vector;
@ -43,12 +44,12 @@ public:
* @param foreground vector of foreground colors
*/
explicit Identiconpp(const uint8_t rows, const uint8_t columns,
const string &background = "ffffffff",
const vector<string> &foreground = { "000000ff" } );
const uint32_t background = 0xffffffff,
const vector<uint32_t> &foreground = { 0x000000ff } );
private:
const uint8_t _rows;
const uint8_t _columns;
const string _background;
const vector<string> _foreground;
const uint32_t _background;
const vector<uint32_t> _foreground;
};