1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

LibWeb: Update SVG <circle> element to use geometry properties

With this the `<circle>` element now correctly parses percentage sizes,
and resolves them relative to the viewport.

The rest of the geometry elements are still left TODO.
This commit is contained in:
MacDue 2024-03-03 20:47:10 +00:00 committed by Andreas Kling
parent 344eb98b3c
commit 74b655d035
6 changed files with 71 additions and 35 deletions

View file

@ -6,6 +6,7 @@
#pragma once
#include <AK/Math.h>
#include <LibWeb/SVG/AttributeParser.h>
#include <LibWeb/SVG/ViewBox.h>
@ -18,4 +19,11 @@ public:
virtual ~SVGViewport() = default;
};
inline CSSPixels normalized_diagonal_length(CSSPixelSize viewport_size)
{
if (viewport_size.width() == viewport_size.height())
return viewport_size.width();
return sqrt((viewport_size.width() * viewport_size.width()) + (viewport_size.height() * viewport_size.height())) / CSSPixels::nearest_value_for(AK::Sqrt2<float>);
}
}