Inkscape.org
Beyond the Basics Problems with converting pattern to object
  1. #1
    Kesellie Kesellie @Kesellie

    Hi!
    Inkscape version 1.4
    I'm currently trying to add some texture to a button that I'm making by duplicating the buttons shape path and then turning on fill pattern on the duplicated one. I duplicated everything cause I wanted to test out the button in another color scheme, but then I noticed that the pattern changed color on both buttons. I had an unresolved issue like this a couple of months ago but got some tips that I could go to object/pattern/pattern to object. This tip didn't and still doesn't work at all cause the pattern stretched out itself, changed color and moved position inside my workspace.

    What I want to do is to transform my pattern from being a fill pattern so that I can change the color of both the pattern and the duplicated pattern individually. For example, the duplicated pattern should have a red color instead of blue like the first pattern. 

    This is a screenshot on the shape that my button has; the left just has a normal color fill and the shape to the right has the pattern color fill

     

     

    Thank you so much for helping me (if you can)!

  2. #2
    David248 David248 @David248

    Feel free to share a file with the button and the pattern.

    You could open xml editor, find the pattern in defs, look at its components and remove their fill color informations n their style attribute, add a style attribute to the pattern, with a (random) fill color. To put it in a nutshell  :  remove fill color information at the level of components for the ones that must be editable, and add one at the level of the pattern in xml tree. 

     

  3. #3
    Kesellie Kesellie @Kesellie
    *

    Hi @David248!
    I went into the XML editor but I am quite lost. I'm not familiar with the XML editor. I searched for "defs" and other things you've named but I don't understand what you meant that I should do.
    The xml editor:

    (I tried to sent over the work file too, but it didn't show up when I sent my reply)

  4. #4
    David248 David248 @David248
    *

    Some explanations :

    If you draw a rectangle, then give it a red fill (RGBA : ff0000ff), keep it selected and open XML Editor, you’ll see its informations. If you click on its style attribute, you’ll get a pop up listing its Style values : as you can see, its fill : value is #ff0000 (forget the end ff of RGBA ff0000ff , it is translated in a fill-opacity value).

    Now, duplicate this rectangle, place it next to the first one and return to Fill and stroke panel and click on ? Icon for the Fill ; this « Unsets » the fill color : allowing the fill color to be inherited from another level (a pattern). On canvas, the visual aspect in a black fill, but actually it is unset. In XML editor, for this the fill :#ff0000 has simply disappeared.

    Select both rectangles and do Object > Object to pattern. This transforms your two rectangles in a new rectangle, whose fill is a pattern. In xml editor, you can see fill: url(#pattern2); the value points to a pattern 2. To find it, you have to go in defs sections of the xml, and if you expand it, you find your two original rectangles forming the pattern. This pattern has some Attributes, but no Style attribute for the moment.

    Now go to Fill & Stroke Panel and modify the color of the pattern to a bright green, for example. In the pop up, notice that you have to be in rgb mode (doesn't work for me in HSL)

    Only the unset color has changed, the red color hasn’t changed. In XML editor, you can see that at the pattern2 level, a new Style Attribute has appeared, with the Fill : corresponding to the color you set. A the pattern level, you can now set the color of all the components of the pattern whose Fill color is unset.

     

     

     

     


  5. #5
    David248 David248 @David248
    *

    Let's add that, if you modify the size of pattern, rotate it, you add a step : in fill a stroke panel, I set a 90° orientation and a 0,5 scale to the pattern, now the rectangle is filled with a pattern3 that refers to pattern2 with a transformation (patternTransform attribute).

    This step explains why, when you do Pattern to object, you get something distorted : it has lost the transformation applied.

     

  6. #6
    Aero Aero @Aero◻️
    Kesellie

    I duplicated everything cause I wanted to test out the button in another color scheme, but then I noticed that the pattern changed color on both buttons.

    Instead of duplicating, try copy then paste.

  7. #7
    David248 David248 @David248

    So, you understand that if you don't want to use Object to pattern to unset the fills of the component of the pattern, you can browse to the pattern2 (for example), inspect each of its components and delete their Fill values in Style attribute.

    Eventually if you can't modify Pattern color in Fill and stroke Panel, you can, in xml editor manually add a Style attribute for pattern2 and type Fill:#ff0000; for its value (for example). This will cure the issue.

  8. #8
    Kesellie Kesellie @Kesellie
    *

    Ah, thank you. I've got to the point where I've duplicated the pattern, set the fill to unset, did objects to pattern and changed the color to for example green. I found the pattern id="pattern1" inkscapelabel="Pattern" in the defs menu. I didn't quite understand the last steps after that. Could you explain further about that last part?

  9. #9
    David248 David248 @David248

    I think you mixed too many things there. On your screenshot, what is selected is considered as an object with a pattern consisting of the blue thing and the green thing. The green thing has an unset color, I think, and has inherited of the 4eb35a color you set at the pattern level.

    Could you attach a svg file, to help you ?

  10. #10
    Kesellie Kesellie @Kesellie

    I can send you the file. 

     

  11. #11
    David248 David248 @David248

    Here is an example file. Open xml editor. Inspect xml :

    • rect 272 is filled with a pattern : xml editor points to pattern273 thats is a transformation of pattern271.
    • pattern271 consists of a path 270, that has a pink fill : hence the pattern color isn't editable, despite pattern271 has a style attribute with fill: #000000;*

    in defs, select pattern271 then click on path270. Click on style attribute and delete fill: #ff2a7f; now the pattern is editable.

    * if pattern271 did not have this attribute, you could have created one in xml editor.

     

    Example
  12. #12
    Kesellie Kesellie @Kesellie
    *

    I have some more questions. I don't seem to find the fill that is pink in the xml editor. Is it perhaps named something else in the xml editor.

    "in defs, select pattern271 then click on path270. Click on style attribute and delete fill: #ff2a7f; now the pattern is editable."

    I can only select/highlight one at the time in the xml editor, not both pattern271 and path270. I've tried to right-click on my computer mouse to maybe get a popup and I've also hovered over the tool option icons in the xml editor but I don't seem to find "style attribute" either.

    It's my first time using the xml editor and I don't have the natural ability to understand the programming-like structure in the xml editor so I thank you for really trying to explain everything thus far. Could you please point out what I'm missing?

  13. #13
    David248 David248 @David248
    *
    Kesellie

    "in defs, select pattern271 then click on path270. Click on style attribute and delete fill: #ff2a7f; now the pattern is editable."

    I meant  : expand pattern271 (click on triangle icon on the left) then (left click on) select path270. When you click on pattern270 line, it becomes selected (highlighted), you see its attributes in the window next to the browser in xml editor. They are arranged in two columns : Name (of the attribute) and value. On the style line, if you left click on the value (on the second column), there is a tiny popup that appears, showing you all the values and allowing you to modify it (you have to click OK button or press shift + enter to valid the modification).

    path270 style values are : fill-rule:evenodd;stroke-width:4.91339;stroke-linecap:round;stroke-linejoin:round;fill:#ff2a7f

    fill:#ff2a7f correspond to a pink fill

     

     

  14. #14
    David248 David248 @David248

    I suppose you want to have a design that correspond to the look of the blue button, where you can modify the color from one button to another.

    You where almost done : you did a mistake by creating a bizarre pattern consisting of the blue and black (unset) button.

    Open object's panel (ctrl+shift+L) and select rect1 and do object : pattern to object. The second object you named Pattern is working fine : you can change its color.

    The toppest object you named Pattern, that has an unset fill can be deleted, rect1 can also be deleted.

    Follow aero's method : to have two buttons with the same design but different color, copy paste instead of duplicate. If you duplicate it, the original and the duplicate share the same pattern : if you modify its color, you modify all instances of the pattern (on the original and the duplicate), if you copy-paste you create a button with its own new pattern, you can change the color of the pattern of the copy, it will not affect the color of the pattern of the original.

  15. #15
    Kesellie Kesellie @Kesellie

    OMG thank you! It solved my issues. Thank you so much for explaining everything.
    Have a nice day. 

Inkscape Inkscape.org Inkscape Forum Beyond the Basics Problems with converting pattern to object