diff options
| author | Alvin Penner <penner@vaxxine.com> | 2015-03-06 17:58:06 +0000 |
|---|---|---|
| committer | apenner <penner@vaxxine.com> | 2015-03-06 17:58:06 +0000 |
| commit | f30550286f21085f0494910c32685f07d14ec978 (patch) | |
| tree | 270c2f5444a9f73423f3e764d8fa7d7d667c825c /src/sp-item-transform.cpp | |
| parent | Fix filter primitives using 'type' attribute. (Broken when 'type' attribute i... (diff) | |
| download | inkscape-f30550286f21085f0494910c32685f07d14ec978.tar.gz inkscape-f30550286f21085f0494910c32685f07d14ec978.zip | |
avoid 0/0 problem in get_scale_transform_for_uniform_stroke. (Bug 1428789)
Fixed bugs:
- https://launchpad.net/bugs/1428789
(bzr r13970)
Diffstat (limited to 'src/sp-item-transform.cpp')
| -rw-r--r-- | src/sp-item-transform.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 86beee907..767f0ed91 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -181,7 +181,9 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua if (B*B - 4*A*C < 0) { g_message("stroke scaling error : %d, %f, %f, %f, %f, %f", preserve, r0, w0, h0, w1, h1); } else { - r1 = fabs((-B - sqrt(B*B - 4*A*C))/(2*A)); + r1 = -C/B; + if (!Geom::are_near(A*C/B/B, 0.0, Geom::EPSILON)) + r1 = fabs((-B - sqrt(B*B - 4*A*C))/(2*A)); // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier scale_x = (w1 - r1)/(w0 - r0); @@ -339,7 +341,9 @@ Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visu if (B*B - 4*A*C < 0) { g_message("variable stroke scaling error : %d, %d, %f, %f, %f, %f, %f, %f", transform_stroke, preserve, r0w, r0h, w0, h0, w1, h1); } else { - gdouble det = (-B + sqrt(B*B - 4*A*C))/(2*A); + gdouble det = -C/B; + if (!Geom::are_near(A*C/B/B, 0.0, Geom::EPSILON)) + det = (-B + sqrt(B*B - 4*A*C))/(2*A); r1w = r0w*det; r1h = r0h*det; // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); |
