wayland rewrite complete
This commit is contained in:
parent
5ff43e240c
commit
721ff8f42f
8 changed files with 134 additions and 87 deletions
|
|
@ -23,8 +23,8 @@ import std;
|
|||
|
||||
namespace Crafter {
|
||||
export struct MousePoint {
|
||||
std::uint_fast32_t x;
|
||||
std::uint_fast32_t y;
|
||||
std::int_fast32_t x;
|
||||
std::int_fast32_t y;
|
||||
};
|
||||
|
||||
export struct MouseMoveEvent {
|
||||
|
|
@ -101,22 +101,45 @@ namespace Crafter {
|
|||
export constexpr std::int_fast32_t SCALE = std::numeric_limits<std::int_fast32_t>::max() / BOUND;
|
||||
export constexpr double SCALEDOUBLE = static_cast<double>(std::numeric_limits<std::int_fast32_t>::max()) / BOUND;
|
||||
|
||||
export constexpr std::int_fast32_t SCALEBOUNDLESS = std::numeric_limits<std::int_fast32_t>::max();
|
||||
export constexpr double SCALEDOUBLEBOUNDLESS = static_cast<double>(std::numeric_limits<std::int_fast32_t>::max());
|
||||
|
||||
export constexpr std::int_fast32_t FractionalToMapped(double f) {
|
||||
return std::int_fast32_t(f * SCALEDOUBLE);
|
||||
}
|
||||
|
||||
export constexpr std::int_fast32_t MappedToPixel(std::int_fast32_t mapped, std::int_fast32_t width) {
|
||||
return mapped / (SCALE / width);
|
||||
}
|
||||
|
||||
export constexpr double MappedToFractional(std::int_fast32_t mapped) {
|
||||
return static_cast<double>(mapped) / SCALEDOUBLE;
|
||||
}
|
||||
|
||||
export constexpr std::int_fast32_t MappedToPixel(std::int_fast32_t mapped, std::int_fast32_t width) {
|
||||
return mapped / (SCALE / width);
|
||||
}
|
||||
|
||||
export constexpr std::int_fast32_t PixelToMapped(std::int_fast32_t pixel, std::int_fast32_t width) {
|
||||
return pixel * (SCALE / width);
|
||||
}
|
||||
|
||||
export constexpr std::int_fast32_t BoundToBoundless(std::int_fast32_t bound) {
|
||||
return bound * BOUND;
|
||||
}
|
||||
|
||||
export constexpr std::int_fast32_t FractionalToMappedBoundless(double f) {
|
||||
return std::int_fast32_t(f * SCALEDOUBLEBOUNDLESS);
|
||||
}
|
||||
|
||||
export constexpr double MappedToFractionalBoundless(std::int_fast32_t mapped) {
|
||||
return static_cast<double>(mapped) / SCALEDOUBLEBOUNDLESS;
|
||||
}
|
||||
|
||||
export constexpr std::int_fast32_t MappedToPixelBoundless(std::int_fast32_t mapped, std::int_fast32_t width) {
|
||||
return mapped / (SCALEBOUNDLESS / width);
|
||||
}
|
||||
|
||||
export constexpr std::int_fast32_t PixelToMappedBoundless(std::int_fast32_t pixel, std::int_fast32_t width) {
|
||||
return pixel * (SCALEBOUNDLESS / width);
|
||||
}
|
||||
|
||||
// export constexpr double bound = 10;
|
||||
|
||||
// export constexpr std::uint_fast32_t FractionalToMapped(double fractional) {
|
||||
|
|
@ -166,8 +189,4 @@ namespace Crafter {
|
|||
|
||||
// return static_cast<std::int_fast32_t>(t * static_cast<double>(size));
|
||||
// }
|
||||
|
||||
export constexpr std::uint_fast32_t PixelToMapped(double pixel, std::uint_fast32_t size) {
|
||||
return static_cast<std::uint_fast32_t>((pixel / size) * static_cast<double>((std::numeric_limits<std::uint_fast32_t>::max() / 10)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue