[librsvg/rustification] rsvg-styles: Use the viewport percentage computation specified in the spec
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustification] rsvg-styles: Use the viewport percentage computation specified in the spec
- Date: Wed, 9 Nov 2016 01:17:46 +0000 (UTC)
commit 7abdac9ee4bd650472869f00ad58b1cc7618bd20
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Nov 8 18:30:41 2016 -0600
rsvg-styles: Use the viewport percentage computation specified in the spec
rsvg-styles.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/rsvg-styles.c b/rsvg-styles.c
index 948333e..de5eb00 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -99,7 +99,13 @@ style_value_data_free (StyleValueData *value)
gdouble
rsvg_viewport_percentage (gdouble width, gdouble height)
{
- return sqrt (width * height);
+ /* https://www.w3.org/TR/SVG/coords.html#Units
+ *
+ * "For any other length value expressed as a percentage of the viewport, the
+ * percentage is calculated as the specified percentage of
+ * sqrt((actual-width)**2 + (actual-height)**2))/sqrt(2)."
+ */
+ return sqrt (width * width + height * height) / M_SQRT2;
}
gdouble
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]