Code

fix pattern transform when doing object-to-pattern within a transformed group
authorbuliabyak <buliabyak@users.sourceforge.net>
Sun, 3 Sep 2006 05:12:58 +0000 (05:12 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Sun, 3 Sep 2006 05:12:58 +0000 (05:12 +0000)
src/selection-chemistry.cpp

index 3d8b5c5aa830fc2bd39aa5a2b9ac121d672bbdd2..94e0b709ab8d519b2031e6700384541a40965778 100644 (file)
@@ -2139,6 +2139,8 @@ sp_selection_tile(bool apply)
     // bottommost object, after sorting
     SPObject *parent = SP_OBJECT_PARENT (items->data);
 
+    NR::Matrix parent_transform = sp_item_i2root_affine(SP_ITEM(parent));
+
     // remember the position of the first item
     gint pos = SP_OBJECT_REPR (items->data)->position();
 
@@ -2166,7 +2168,7 @@ sp_selection_tile(bool apply)
     prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
 
     const gchar *pat_id = pattern_tile (repr_copies, bounds, document,
-                                        NR::Matrix(NR::translate(desktop->dt2doc(NR::Point(r.min()[NR::X], r.max()[NR::Y])))), move);
+                                        NR::Matrix(NR::translate(desktop->dt2doc(NR::Point(r.min()[NR::X], r.max()[NR::Y])))) * parent_transform.inverse(), parent_transform * move);
 
     // restore compensation setting
     prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
@@ -2174,10 +2176,14 @@ sp_selection_tile(bool apply)
     if (apply) {
         Inkscape::XML::Node *rect = sp_repr_new ("svg:rect");
         rect->setAttribute("style", g_strdup_printf("stroke:none;fill:url(#%s)", pat_id));
-        sp_repr_set_svg_double(rect, "width", bounds.extent(NR::X));
-        sp_repr_set_svg_double(rect, "height", bounds.extent(NR::Y));
-        sp_repr_set_svg_double(rect, "x", bounds.min()[NR::X]);
-        sp_repr_set_svg_double(rect, "y", bounds.min()[NR::Y]);
+
+        NR::Point min = bounds.min() * parent_transform.inverse();
+        NR::Point max = bounds.max() * parent_transform.inverse();
+
+        sp_repr_set_svg_double(rect, "width", max[NR::X] - min[NR::X]);
+        sp_repr_set_svg_double(rect, "height", max[NR::Y] - min[NR::Y]);
+        sp_repr_set_svg_double(rect, "x", min[NR::X]);
+        sp_repr_set_svg_double(rect, "y", min[NR::Y]);
 
         // restore parent and position
         SP_OBJECT_REPR (parent)->appendChild(rect);