feat: rotate mode angle offset

close #4
This commit is contained in:
Virt 2024-06-29 11:06:52 +02:00
commit bbe4709926
4 changed files with 10 additions and 0 deletions

View file

@ -7,6 +7,7 @@ EModeUpdate CModeRotate::strategy() {
double CModeRotate::update(Vector2D pos) {
static auto* const* PLENGTH = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, CONFIG_LENGTH)->getDataStaticPtr();
static auto* const* POFFSET = (Hyprlang::FLOAT* const*)HyprlandAPI::getConfigValue(PHANDLE, CONFIG_ROTATE_OFFSET)->getDataStaticPtr();
// translate to origin
end.x -= pos.x;
@ -25,6 +26,7 @@ double CModeRotate::update(Vector2D pos) {
double angle = -std::atan(end.x / end.y);
if (end.y > 0) angle += PI;
angle += PI;
angle += **POFFSET * ((2 * PI) / 360); // convert to radiants
// translate back
end.x += pos.x;