MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / rasterize

Function rasterize

examples/shadertui/run.cpp:16–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15template <size_t rows, size_t cols>
16void rasterize(const std::array<float, rows * cols> &values,
17 std::array<char, rows *(cols + 1)> &raster) {
18 // Note: We can experiment with the rasterization characters here but fewer
19 // characters looks better by imposing temporal coherence whereas more
20 // characters can start to look like noise.
21 // static const char intensity[] = " `.-':_,^=;><+!ngrc*/z?sLTv)J7(|Fi{C}fI31tlu[neoZ5Yxjya]2ESwqkP6h9d4VpOGbUAKXHm8RD#$Bg0MNWQ%&@";
22 static const char intensity[] = " .`'^-+=*x17X$8#%@";
23 for (size_t i = 0; i < rows; ++i) {
24 for (size_t j = 0; j < cols; ++j) {
25 // values ranges b/w 0 and 1
26 size_t index =
27 std::min(sizeof(intensity) - 2,
28 std::max(0ul, static_cast<size_t>(values[i * cols + j] *
29 (sizeof(intensity) - 2))));
30 raster[i * (cols + 1) + j] = intensity[index];
31 }
32 raster[i * (cols + 1) + cols] = '\n';
33 }
34}
35
36float getCurrentTimeInMilliseconds(
37 std::chrono::time_point<std::chrono::high_resolution_clock> &zeroTime) {

Callers 1

mainFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected