How to apply transforms to paths, rectangles etc.

Asked by shinyblue on 2017-03-13

Demo case (will attach svg): I have two rectangles with identical calculated sizes that I wish to apply the same filter to. Currently the filter comes out radically differently on each rectangle.

Excepting the demo case with two colour-filled rectangles, in my real world problem these numerous rectangles have been positioned and sized over many hours designing; they contain carefully positioned pattern fills.

The problem is that the rectangles (happy to use paths that describe rectangle but interested in both cases), which have been scaled as part of a group, have different co-ordinate lengths and transforms, even though the result of the combination of those is the same set of lengths. e.g. one might be d='m 0,0 v 1 h 1 v-1 z' with an identity/no transform, and the other might be d='m 0,0 v2 h2 v-2 z' with a transform that scales it 50%.

It seems the filters are applied on the pre-transformed size, meaning that when the filter is applied to the second it is "zoomed in", for want of a better description.

I've come across this problem lots of times, e.g. text sizes are another example, where you want to apply the scale transform to the actual lengths. For a path made of nodes, this seems at least a possibility for any transform matrix; I understand that you can't apply all transforms on other native objects like shapes or text.

Is there a way to do this sort of transform normalization?

Question information

Language:
English Edit question
Status:
Answered
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Last query:
2017-03-13
Last reply:
2017-03-15
shinyblue (shinyblue) said : #1

Here's a demo SVG.

<code>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="210mm"
   height="297mm"
   viewBox="0 0 210 297"
   version="1.1"
   id="svg1746"
   inkscape:version="0.92pre1 unknown"
   sodipodi:docname="demo.svg">
  <defs
     id="defs1740">
    <filter
       style="color-interpolation-filters:sRGB"
       inkscape:label="d1"
       id="filter501"
       x="-0.30000001"
       y="-0.30000001"
       width="1.6"
       height="1.6">
      <feFlood
         flood-opacity="0.498039"
         flood-color="rgb(0,0,0)"
         result="flood"
         id="feFlood491" />
      <feComposite
         in="flood"
         in2="SourceGraphic"
         operator="in"
         result="composite1"
         id="feComposite493" />
      <feGaussianBlur
         in="composite1"
         stdDeviation="7.18232"
         result="blur"
         id="feGaussianBlur495" />
      <feOffset
         dx="5.5"
         dy="6.4"
         result="offset"
         id="feOffset497" />
      <feComposite
         in="SourceGraphic"
         in2="offset"
         operator="over"
         result="composite2"
         id="feComposite499" />
    </filter>
  </defs>
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="0.35"
     inkscape:cx="400"
     inkscape:cy="560"
     inkscape:document-units="mm"
     inkscape:current-layer="layer1"
     showgrid="false" />
  <metadata
     id="metadata1743">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1">
    <path
       style="fill:#00ffff;stroke:none;stroke-width:3.04062223;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter501)"
       d="m -977.61786,-145.28835 c 35.27777,0 70.55554,0 105.83331,0 0,22.8677 0,45.735387 0,68.603078 -35.27777,0 -70.55554,0 -105.83331,0 0,-22.867691 0,-45.735378 0,-68.603078 z"
       id="rect116"
       inkscape:connector-curvature="0"
       transform="matrix(0.87016183,0,0,0.87016183,851.28139,191.34918)" />
    <path
       style="fill:#00ffff;stroke:none;stroke-width:11.49211502;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter501)"
       d="m 1016.7031,-1313.5352 v 259.2872 h 400 v -259.2872 z"
       transform="matrix(0.23023033,0,0,0.23023033,-232.82725,302.01948)"
       id="rect102"
       inkscape:connector-curvature="0" />
  </g>
</svg>
</code>

Hachmann (marenhachmann) said : #2

Sorry, don't have time to test this now, but there is an extension that applies transformations to objects:

Also see http://www.inkscapeforum.com/viewtopic.php?t=27459
and the extension can be found at:
http://wiki.inkscape.org/wiki/index.php/Inkscape_Extensions

Kind Regards,
 Maren

Can you help with this problem?

Provide an answer of your own, or ask shinyblue for more information if necessary.

To post a message you must log in.