40

How can I color a pattern in Inkscape without creating a custom pattern? I guess this should be possible, but can't make it work.

I draw a square and fill it with a color (green). Then I choose a standard pattern for the square. The green fill is gone and I have a black pattern. Now I would like to change the pattern's color. How can I do this?

pattern and stroke in Inkscape

2

3 Answers 3

40

The easiest way I figured out is probably this:

  1. Draw a figure.
  2. Select the pattern from Fill and Stroke ("Füllung und Kontur").
  3. Click Extensions > Colour > Replace colour .. (should be something like Erweiterungen > Farbe > Farbe ersetzen in German).
  4. Enter the hex code for your desired colour.

Another way:

  1. Select Edit >> XML Editor.
  2. Expand svg:defs >> svg:pattern id="Strips1_1".
  3. Select svg:rect.
  4. Click style.
  5. Set fill to the RGB hex code (including the #).
  6. Click Set to apply the changes.

Set Stripe Colour

4
  • 1
    +1 for the XML editor alternative. I think a lot of people are unaware that this feature is there and how powerful it can be. Oct 2, 2015 at 11:25
  • 3
    Hoping for a more sane UI way of doing this in future Inkscape versions! Oct 18, 2017 at 8:37
  • Interesting to note that no matter what, but this won't work, neither through the Extension menu nor by the XML editor, if I have Polka dots: the setting reads the color that I effectively assigned, but the updated rendering is still black apparently.
    – maurizio
    Jun 11, 2020 at 6:21
  • 1
    Is this still a good way to do this? Using inkscape 1.0 Aug 6, 2020 at 19:31
7

If, like me, you're unable to use any extensions due to multiple incompatible python installations (not an uncommon problem) it's still possible, but best in a simple file (and much easier if you don't save optimised SVG,which you can't without extensions):

  • Set the pattern you want for the object you want
  • Save the file
  • Open it in a decent text editor (notepad++ works nicely on windows, especially if you tell it to use XML syntax highlighting for .SVGs).
  • Find the pattern definition near the top of the file (if you only have 1, search for "pattern").
  • Look for the next line with style="fill:????;stroke:????" /> (in my case fill:black).
  • Select down to the bottom of the pattern definition.
  • Find/replace all within selection: Find the original fill colour, replace with the new one, e.g. Find black, replace #808080 and you'll get grey.
  • Save and reopen in inkscape.
  • To attach the pattern color to a Swatch, replace the fill or stroke color value with the url syntax and the Swatch name. For example, create a swatch named Black then replace with fill:url(#Black) and the pattern's fill color will be tied to the Black Swatch, allowing easy updates in Inkscape.
5

By example:

Suppose you made a circle and you want its fill pattern to be green vertical bars.

  1. Make a thin green rectangle somewhere in some blank space (size is irrelevant).
  2. copy the green rectangle. Position the copy some reasonable distance to the right (this will be the relative spacing of your pattern).
  3. select the two green rectangles and press Alt + I (hotkey for "object --> pattern --> object to pattern").
  4. select the circle. when you go to fill pattern, there will now be a custom pattern in the drop-down menu. e.g. "pattern7165". select this pattern.
  5. Now you've got green vertical bars!
  6. (you may now delete the two rectangles that served as the template for the pattern).
1
  • The question asked for a method not requiring custom patterns.
    – henrebotha
    May 25, 2022 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.