mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +00:00
LibGfx: Add ability to get a bounding box from a Path
This commit is contained in:
parent
4155de2572
commit
236eeb6fb1
2 changed files with 43 additions and 4 deletions
|
@ -33,6 +33,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Point.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -174,13 +175,22 @@ public:
|
|||
const NonnullRefPtrVector<Segment>& segments() const { return m_segments; }
|
||||
const auto& split_lines()
|
||||
{
|
||||
if (m_split_lines.has_value())
|
||||
return m_split_lines.value();
|
||||
segmentize_path();
|
||||
ASSERT(m_split_lines.has_value());
|
||||
if (!m_split_lines.has_value()) {
|
||||
segmentize_path();
|
||||
ASSERT(m_split_lines.has_value());
|
||||
}
|
||||
return m_split_lines.value();
|
||||
}
|
||||
|
||||
const Gfx::FloatRect& bounding_box()
|
||||
{
|
||||
if (!m_bounding_box.has_value()) {
|
||||
segmentize_path();
|
||||
ASSERT(m_bounding_box.has_value());
|
||||
}
|
||||
return m_bounding_box.value();
|
||||
}
|
||||
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
|
@ -199,6 +209,7 @@ private:
|
|||
NonnullRefPtrVector<Segment> m_segments {};
|
||||
|
||||
Optional<Vector<SplitLineSegment>> m_split_lines {};
|
||||
Optional<Gfx::FloatRect> m_bounding_box;
|
||||
};
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, const Path& path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue