mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-10-17 02:45:05 +00:00
Fixes
This commit is contained in:
parent
ae0d002f36
commit
628f7b2b0c
@ -3,10 +3,13 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <numbers>
|
||||||
|
|
||||||
|
constexpr double INV_SQRT2 = 1.0 / std::numbers::sqrt2;
|
||||||
|
|
||||||
// The part of a corner's square that a circle with the given radius cuts off along its diagonal
|
// The part of a corner's square that a circle with the given radius cuts off along its diagonal
|
||||||
static int32_t corner_inset(int32_t radius) {
|
static int32_t corner_inset(int32_t radius) {
|
||||||
return static_cast<int32_t>(std::ceil(radius * (1.0 - M_SQRT1_2)));
|
return static_cast<int32_t>(std::ceil(radius * (1.0 - INV_SQRT2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// The horizontal distance between a circle's edge and its bounding box at the given distance from the circle's center row
|
// The horizontal distance between a circle's edge and its bounding box at the given distance from the circle's center row
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <app/paths.h>
|
#include <app/paths.h>
|
||||||
|
|
||||||
|
#include <charconv>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -27,7 +28,14 @@ static std::optional<uint32_t> parseColor(const std::map<std::string, std::strin
|
|||||||
if (entry == map.end() || entry->second.empty()) {
|
if (entry == map.end() || entry->second.empty()) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
return static_cast<uint32_t>(std::strtoul(entry->second.c_str(), nullptr, 16)) & 0xFFFFFF;
|
// An invalid value (e.g. from a hand-edited file) counts as unset, rather than as black
|
||||||
|
const std::string& text = entry->second;
|
||||||
|
uint32_t color = 0;
|
||||||
|
const auto [end, error] = std::from_chars(text.data(), text.data() + text.size(), color, 16);
|
||||||
|
if (error != std::errc {} || end != text.data() + text.size() || color > 0xFFFFFF) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saving only updates the keys that are written, so an unset colour is written as an empty value
|
// Saving only updates the keys that are written, so an unset colour is written as an empty value
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user