Code

Fix for eccentric elliptic gradients.
authorulferikson <ulferikson@users.sourceforge.net>
Sat, 5 Aug 2006 21:07:34 +0000 (21:07 +0000)
committerulferikson <ulferikson@users.sourceforge.net>
Sat, 5 Aug 2006 21:07:34 +0000 (21:07 +0000)
src/extension/internal/pdf.cpp

index 50e98d00c2dee8e351c3b27d140e3f94e13678cb..bd65cd3182d8df11f1ce5028418306f54f3a246c 100644 (file)
@@ -685,6 +685,13 @@ PrintPDF::print_fill_alpha(SVGOStringStream &os, SPStyle const *const style, NRR
             NR::Point c (rg->cx.computed, rg->cy.computed);\r
             NR::Point f (rg->fx.computed, rg->fy.computed);\r
             double r = rg->r.computed;\r
+\r
+            NR::Coord const df = hypot(f[NR::X] - c[NR::X], f[NR::Y] - c[NR::Y]);\r
+            if (df >= r) {\r
+                f[NR::X] = c[NR::X] + (f[NR::X] - c[NR::X] ) * r / (float) df;\r
+                f[NR::Y] = c[NR::Y] + (f[NR::Y] - c[NR::Y] ) * r / (float) df;\r
+            }\r
+\r
             if (pbox && SP_GRADIENT(rg)->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {\r
                 // convert to userspace\r
                 NR::Matrix bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0);\r
@@ -877,6 +884,13 @@ PrintPDF::print_fill_style(SVGOStringStream &os, SPStyle const *const style, NRR
             NR::Point c (rg->cx.computed, rg->cy.computed);\r
             NR::Point f (rg->fx.computed, rg->fy.computed);\r
             double r = rg->r.computed;\r
+\r
+            NR::Coord const df = hypot(f[NR::X] - c[NR::X], f[NR::Y] - c[NR::Y]);\r
+            if (df >= r) {\r
+                f[NR::X] = c[NR::X] + (f[NR::X] - c[NR::X] ) * r / (float) df;\r
+                f[NR::Y] = c[NR::Y] + (f[NR::Y] - c[NR::Y] ) * r / (float) df;\r
+            }\r
+\r
             if (pbox && SP_GRADIENT(rg)->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {\r
                 // convert to userspace\r
                 NR::Matrix bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0);\r