From 8b15224a6039fd88c5c778a73e452fcfb8d404c6 Mon Sep 17 00:00:00 2001 From: Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> Date: Sun, 15 Mar 2020 17:41:22 +1100 Subject: [PATCH] Apply inset/outset consistently in document (#775) Different display units, or transforms on groups no longer affect inset/outset operations. Improvements to width calculation from Thomas Holder. (cherry picked from commit bca6cd49699, 3a9df5bcce) --- src/splivarot.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/splivarot.cpp b/src/splivarot.cpp index e1daea751f..2e63768fd3 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1558,6 +1558,7 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool } Geom::Affine const transform(item->transform); + float scaling_factor = item->i2doc_affine().descrim(); item->doWriteTransform(item->getRepr(), Geom::identity()); @@ -1572,12 +1573,11 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool float o_width = 0; { - { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); - } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); + o_width /= scaling_factor; - if (o_width < 0.01){ + if (scaling_factor == 0 || o_width < 0.01) { o_width = 0.01; } } @@ -1718,7 +1718,12 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool - +/** + * Apply offset to selected paths + * @param desktop Targetted desktop + * @param expand True if offset expands, False if it shrinks paths + * @param prefOffset Size of offset in pixels + */ void sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) { @@ -1751,6 +1756,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) continue; Geom::Affine const transform(item->transform); + float scaling_factor = item->i2doc_affine().descrim(); item->doWriteTransform(item->getRepr(), Geom::identity()); @@ -1777,10 +1783,12 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) break; } - o_width = prefOffset; + // scale to account for transforms and document units + o_width = prefOffset / scaling_factor; - if (o_width < 0.1) - o_width = 0.1; + if (scaling_factor == 0 || o_width < 0.01) { + o_width = 0.01; + } o_miter = i_style->stroke_miterlimit.value * o_width; } -- GitLab