Author Topic: Pattern Fill Inconsistent?  (Read 4254 times)

March 07, 2017, 02:18:38 AM
Read 4254 times

Trygon

  • Sr. Newbie

  • Offline
  • **

  • 4
I have been having trouble applying consistent pattern fills to a group of objects. I believe I have traced the problem to the use of scale transformations used in the original SVG file.

1) The test file Quad2.svg is a group containing two rectangles, the bottom one being a scaled version of the top one. In Inkscape (0.92) the top rectangle is rendered with a 4mm stroke width and the bottom rectangle with a 2mm stroke width (4mm x scale factor of 0.5) as expected.

2) If the group is selected and a new stroke width of 3mm is applied, both rectangles now have a stroke width of 3mm, as expected. Looking at the raw SVG output from Inkscape following this edit:
a) the top rectangle has a stroke width of 3mm applied
b) the bottom rectangle has a stroke width of 6mm applied which after the scale transformation of 0.5 gives the desired 3mm stroke width

3) However if the group is selected and a pattern fill is applied, it is not the same in both rectangles, which to me is unexpected. In this case, unlike adjusting the stroke width,  Inkscape does not make any allowance for the scale transformation.

Questions:
1) Is this a bug?
2) Is there any way to apply consistent pattern fills to a group of shapes?

Thanks for your help.

Quad2.svg
*Quad2.svg
(0.61 kB . 210x297)
(viewed 666 times)

March 07, 2017, 10:09:22 AM
Reply #1

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Hi.

With 2) I get 3 mm strokes on both rectangles.
There is a chance the behave interferes with the transformation setting -preserve/optimized, and the scale options in the toolbar.
However with drawn shapes there is not much you can do.
A rectangle object can be useful to retain any certain transformations -like it can be used to draw the exact length in any direction after rotating and changing the height/width with the rectangle tool.

There is an extension somewhere that can remove all unnecessary transformations, but as long as those objects are rectangles or shapes, and not paths, they will be necessary and likely present.
A brute-force solution would be converting all objects to paths -and maybe some deep ungrouping as well.
Or to group each individual objects and add the pattern fill to the -untransformed- groups, although that could result in a really overcomplicated structure (theoreticaly should work I guess).
« Last Edit: March 07, 2017, 03:54:37 PM by Lazur »

March 07, 2017, 10:32:23 AM
Reply #2

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Which version of Inkscape are you using?

I have a question for your step #2.  When you say "it's not that same in both rectangles", what is not the same?  Do you mean you expect that the pattern should be scaled along with the object?  As far as I understand, it's not supposed to.....although it seems like recently someone mentioned possibly asking for such an option.  I don't remember enough to be able to search it out.  But you're welcome to search the bug tracker https://launchpad.net/inkscape.  If you don't find a request already reported, you're welcome to submit one.

However, there is a functionality to scale the pattern, using pattern handles.  Let me know if you'd like instructions.  They're rather lengthy, and it sounds like you might already know enough to be able to find them on your own.  But I'm glad to write them for newbies who need it.

Or, when you said "it's not the same", did you mean that the stroke width is no longer behaving as before?

I agree with Lazur that the correct behavior for your 2nd step should be that both rectangles should have the new stroke width.  Possibly in an earlier version of Inkscape, this behavior can be found.  But I can't reproduce it with 0.92 64-bit.  (Windows 7 Pro, 64-bit)

For your question #1, I don't see evidence of a bug so far.  But I'm not sure I understand completely what you're expecting.

For question #2, what do you mean by "consistent pattern fills to a group of shapes"?

Note, in case you weren't aware of it, the option for scaling the stroke with along with the object can be disabled.  So it's not a behavior of Inkscape which can't be changed.  You don't have to always be calculating things to make it work for your particular project or preference.  It's a button on the Selection contol bar which look like this   :ssw:

PS - thanks for such a detailed question  :)
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

March 08, 2017, 04:09:27 AM
Reply #3

Trygon

  • Sr. Newbie

  • Offline
  • **

  • 4
Lazur & brynn thank you for all your helpful thoughts and comments. I think my original post was perhaps too brief, so I will expand on it:

My original SVG code (Quad2.svg) is as follows:

  <g fill="none" stroke="black" stroke-width="4">
    <g>
      <path d="M 10,10 L 100,10 100,80 10,80 Z"/>
    </g>
    <g transform="translate(5,100) scale(0.5)">
      <path d="M 10,10 L 100,10 100,80 10,80 Z"/>
    </g>
  </g>

As can be seen the second rectangle has exactly the same path points as the first, but it is transformed with a translation(5,100) and scale(0.5). Hence it appears further down the page and smaller. The path stroke width is set at 4mm for the overall group, but for the second rectangle this width is scaled down by a factor of 0.5 so displays as 2mm wide. All as expected and OK so far.

If the stroke width for this group is set to 3mm in Inkscape (version 0.92), both rectangles display with a stroke width of 3mm, which IMO is correct. Saving the file gives SVG of this form:

  <g>
      <path
         style="stroke-width:3
         d="M 10,10 L 100,10 100,80 10,80 Z"
      />
  </g>
  <g
 transform="translate(5,100) scale(0.5)">
      <path
         style="stroke-width:6"
         d="M 10,10 L 100,10 100,80 10,80 Z"
      />
  </g>

As can be seen Inkscape has (correctly) achieved a display width of 3mm for the second rectangle by applying a width of 6mm PRIOR to the 0.5 scaling, i.e. 6mm x 0.5 = 3mm display width.

However if a pattern fill is applied to the rectangles it displays at different scales in the two shapes, which IMO is incorrect. This is because Inkscape makes no allowance for the 0.5 scale factor applied to the second rectangle. This behaviour is clearly different to the stroke width edit where Inkscape takes the 0.5 scale factor into account (setting the raw width to 6mm, to give a 3mm display width after scaling).

March 08, 2017, 04:31:41 AM
Reply #4

Trygon

  • Sr. Newbie

  • Offline
  • **

  • 4
Lazur you are correct, "A brute-force solution would be converting all objects to paths -and maybe some deep ungrouping as well." Ungrouping does indeed remove the transforms by applying them to the path points. Taking Quad2.svg and ungrouping once gives SVG of this form:

  <g style="stroke-width:4">
    <path
       d="m 10,10 h 90 V 80 H 10 Z" />
  </g>
  <g
     style="stroke-width:4"
     transform="matrix(0.5,0,0,0.5,5,100)">
    <path
       d="m 10,10 h 90 V 80 H 10 Z" />
  </g>

The original transform is still present, but has been converted into a single equivalent transform matrix.

Ungrouping a second time gives SVG of this form:

  <path
     style="stroke-width:4"
     d="m 10,10 h 90 V 80 H 10 Z"
  />
  <path
     style="stroke-width:2"
     d="m 10,105 h 45 v 35 H 10 Z"
  />

The transform has been removed by applying it to the path points for the second rectangle.  If a pattern fill in now applied it comes out at the same scale for both rectangles.

Thank you, this is exactly what I needed. However IMO this approach should not be necessary, setting a pattern fill should behave the same as setting a stroke width: consistent scaling/size across all shapes in the group.

March 08, 2017, 10:46:50 AM
Reply #5

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Glad it worked!

I think transformations are a tough part to handle with inkscape generally. The drawing process always adds in transformations, the svg standard enables them and the renderer won't choke on stacked multiple transformations -yet there is hardly any control to set them up/apply them at some part of the interface.
On a side note blender has the option of applying transformations so it's more of a conceptual part of inkscape (and the svg specs a bit) how the drawing is structured.

March 08, 2017, 01:48:59 PM
Reply #6

Trygon

  • Sr. Newbie

  • Offline
  • **

  • 4
brynn mentioned the pattern handles for adjusting a pattern fill, I assume these are the cross, square & circle that appear when selecting a pattern filled shape with the node select tool. Is there any way to directly, and therefore precisely, set these parameters e.g. pattern rotation in degrees? (This would be similar to double left clicking on a guideline to set its angle exactly.)

March 08, 2017, 02:22:28 PM
Reply #7

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
You can snap those as well to path nodes etc. and rotate them while holding Ctrl.
However it "may not be perfect", whatever that would be.
Like, if you set a radial gradient and skew the object, its handles will transform accordingly to the transformation of the object and not remain perpendicular as expected (?) although the gradient shape would still be made of ellipses with horizontal and vertical axises.
Similarly, snapping one pattern handle for the rotation may not ensure a correct skewing value if you skewed the object before.
Needs testing.

March 09, 2017, 06:10:24 AM
Reply #8

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Oh good, I thought you might be able to find the pattern handles on your own.  Unfortunately it's not possible to set them at specific values.  But as Lazur said, they should be snappable, which  means you could set guides or use grids, to overcome that.

Actually I think double-clicking on the pattern handles to set their location or rotation degree, just like on guides would be a nice new feature!  No idea how hard or easy to implement.  Also not sure if that would affect being able to apply the pattern elsewhere on the canvas.

I'm still lost with your original problem (been out with the flu, and not 100% yet).  But for that problem, if you think it's a bug, you're more than welcome to report it, and if lucky get a discussion with a developer!  You could also submit a feature request for the pattern hande thing.  Both bugs and feature requests are handled on Launchpad https://launchpad.net/inkscape  Info to prepare for filing your first bug report:  https://inkscape.org/en/contribute/report-bugs/
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann