Skip to content

Commit 76effd2

Browse files
authored
Merge pull request #9 from cpp-gamedev/pini
Added color support
2 parents 8baded5 + b5ed3fd commit 76effd2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/main.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <cassert>
2-
#include <filesystem>
2+
#include <cstdint>
33
#include <iostream>
44
#include <set>
55
#include <context.hpp>
@@ -113,13 +113,22 @@ class clock_ticker_t {
113113
};
114114
} // namespace
115115

116+
u32 random_number(u32 min, u32 max) {
117+
std::random_device r;
118+
std::default_random_engine re(r());
119+
std::uniform_int_distribution<u32> uniform_dist(min, max);
120+
return uniform_dist(re);
121+
}
122+
116123
bool load_timezones(std::filesystem::path const& filename, world_clock_t& clock) {
117124
pn::pini timezones;
118125
if (!timezones.load_file(filename)) { return false; }
119126

120127
for (auto& pair : timezones) {
121-
std::cout << pair.first << " " << pair.second << '\n';
122-
clock.add(pair.first, 0xff8800ff, timezones.get_double(pair.first));
128+
u32 color = random_number(255, UINT32_MAX);
129+
color |= 0xff;
130+
std::cout << pair.first << " " << pair.second << " " << std::hex << color << '\n';
131+
clock.add(pair.first, color, timezones.get_double(pair.first));
123132
}
124133
return true;
125134
}

0 commit comments

Comments
 (0)