mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibDraw: Add dx/dy_relative_to() helper functions for Points
This commit is contained in:
parent
f0a82e1bcc
commit
70a2355963
Notes:
sideshowbarker
2024-07-19 10:39:05 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/70a23559638 Pull-request: https://github.com/SerenityOS/serenity/pull/920
1 changed files with 14 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/LogStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibDraw/Orientation.h>
|
||||
|
||||
class Rect;
|
||||
|
@ -107,14 +107,20 @@ public:
|
|||
set_y(value);
|
||||
}
|
||||
|
||||
// Returns pixels moved from other in either direction
|
||||
int pixels_moved(const Point &other) const
|
||||
int dx_relative_to(const Point& other) const
|
||||
{
|
||||
auto pixels_moved = max(
|
||||
abs(other.x() - x()),
|
||||
abs(other.y() - y())
|
||||
);
|
||||
return pixels_moved;
|
||||
return x() - other.x();
|
||||
}
|
||||
|
||||
int dy_relative_to(const Point& other) const
|
||||
{
|
||||
return y() - other.y();
|
||||
}
|
||||
|
||||
// Returns pixels moved from other in either direction
|
||||
int pixels_moved(const Point& other) const
|
||||
{
|
||||
return max(abs(dx_relative_to(other)), abs(dy_relative_to(other)));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Reference in a new issue