Fixed range check for grayscale output

This commit is contained in:
Bob Polis 2022-01-14 10:56:04 +01:00
parent 387c07210e
commit 1629622bff

View File

@ -1,7 +1,7 @@
#include "iomanip.hpp" #include "iomanip.hpp"
static std::ostream& gray(std::ostream& out, int val, int code) { static std::ostream& gray(std::ostream& out, int val, int code) {
if (val < 0 || val > 24) { if (val < 0 || val > 23) {
throw std::invalid_argument("gray value out of range"); throw std::invalid_argument("gray value out of range");
} }
out << "\x1b[" << code << ";5;" << 232 + val << "m"; out << "\x1b[" << code << ";5;" << 232 + val << "m";