1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:17:35 +00:00

LibGfx+PixelPaint: Add Point::end_point_for_aspect_ratio method

Previously we only had `Point::end_point_for_square_aspect_ratio`,
which was convenient for PixelPaint but assumed the aspect ratio
was always fixed at 1. This patch replaces it with a new mthod that
takes in an arbitrary aspect ratio and computes the end point based
off that.

There's some explicit casting going on in `Point.cpp` to ensure that
the types line up, since we're templating Point based on `T`.`
This commit is contained in:
Mustafa Quraish 2021-09-15 19:34:50 -04:00 committed by Andreas Kling
parent 5c244a7893
commit f14c891ba5
4 changed files with 15 additions and 10 deletions

View file

@ -231,7 +231,7 @@ public:
return { AK::abs(dx_relative_to(other)), AK::abs(dy_relative_to(other)) };
}
[[nodiscard]] Point end_point_for_square_aspect_ratio(Point const&) const;
[[nodiscard]] Point end_point_for_aspect_ratio(Point const& previous_end_point, float aspect_ratio) const;
template<typename U>
[[nodiscard]] Point<U> to_type() const