Inkscape.org
Beyond the Basics Best method for diagonal hatching -- what is the "hatches.svg" file for?
  1. #1
    David.P David.P @David.P
    *

    Hi Forum,

    what would be the best way to create seamless vector hatching in Inkscape? I found below four possible approaches, however have difficulties applying them.

    Firstly, someone once created a number of diagonal and cross hatch patterns for Inkscape. These need to be entered into the Inkscape file "patterns.svg" in the directory \Inkscape\share\inkscape\paint.

    Their syntax goes like this, for example:

    <pattern id="Hatch1.0x135"
    inkscape:stockid="Hatch 1.0 x -45°"
    x="0" y="0" width="5.345059133378628" height="5.345059133378628"
    patternUnits="userSpaceOnUse">
      <path
         style="stroke:#000000;stroke-width:0.25mm"
         d="M 1.5655315743235096,-3.7795275590551185 9.124586692433747,3.7795275590551185"/>
      <path
         style="stroke:#000000;stroke-width:0.25mm"
         d="M -3.7795275590551185,-3.7795275590551185 9.124586692433747,9.124586692433747"/>
      <path
         style="stroke:#000000;stroke-width:0.25mm"
         d="M -3.7795275590551185,1.5655315743235096 3.7795275590551185,9.124586692433747"/>
    </pattern>

    ...which creates a diagonal seamless hatch pattern that looks like this: 

    However, these hatches are too coarse for my purpose, and maybe there is an easier syntax than the one used there?
     

    Secondly, I found something related here: Simple fill pattern in svg: diagonal hatching

    According to this, as I understand, there seems to be a native hatch function in the SVG specification, which should be easier than the tiling code of the above.
    However, I don't know whether or how this would be applicable to Inkscape.
     

    Then there is this third option which works pretty well in my opinion:

    "The way to do proper hatching is to draw 2 vertical lines with a space between each inter alia, select both lines, and then do the convertion "Object to Pattern" (Alt+I). Then, you can adapt+configure the hatching with the F2 trick shown [further] above.


    Fourth, I found this file called "hatches.svg" in the directory \Inkscape\share\inkscape\paint. The syntax used therein goes like this:

    <hatch inkscape:collect="always"
    id="hatch1" hatchUnits="userSpaceOnUse" pitch="15">
    <hatchpath stroke="#000000" offset="5" stroke-width="2" />
    </hatch>


    This looks like the simplest possible syntax for vector hatching to me, using only Pitch, Offset and Stroke-Width.

    However, I can't seem to find a way to access these hatchings defined in the hatches.svg file in the Inkscape user interface?

    Is this SVG v.2 related which does not seem to be released yet, and therefore not yet available in Inkskape?

     

    Thanks for all tips on what is the best method for vector hatching in Inkscape!

  2. #2
    David.P David.P @David.P

    Since I still can't figure out how to do a vector hatch properly, at least I add some more links where people seem to have figured it out:

    https://vektorrascheln.de/posts/2016/Jan/inkscape-entdecker-farben2.html

    https://www.thingiverse.com/thing:4943

    https://blogs.otago.ac.nz/si-geology/resources/illustrationgraphics-resources/usgs-inkscape-pack-instructions-and-download-link/

  3. #3
    Maren Hachmann Maren Hachmann @Moini
    😀

    Hi - I've created a fork of the original Eggbot Hatch fill extension here:

    https://gitlab.com/moini_ink/hatch_fill/

    Improvements include:

    • Updated to work with Inkscape 1.0 and higher
    • Simplified a small portion of the code
    • Added the option to choose units for the hatch distance and inset
    • Only depends on inkex now, which makes installation much easier
  4. #4
    oblio oblio @oblio

    @Moini  Thanks for the Hatch fill extension.  I am using Inkscape 92.5 on a Windows 7 machine  and I loaded the hatch_fill.inx &.py files in my user directory (...\AppData\Roaming\inkscape\extensions) in the hope that it might work on pre-1.0.  The extension shows up in the Extensions>Generate from path menu and opens the dialog box (options/arguments).  When 'Apply' is clicked the following error dialog is generated:

     

    I'm guessing this is because I'm not using Inkscape 1.0?  I went to the EggBot Github site and found eggbot_hatch.inx &.py under the EggBot/Inscape_driver directory.  These looked to be purpose built to operate the EggBot device from Inkscape so I did not load them.

    Am I missing something that is a relatively simple solution to allowing this extension to operate on 92.5 (like editing the .inx and/or .py files or copying code from other 92.5 extensions)  or is it a major recode and best to wait until I have installed Inkscape 1.0?

    Thanks for your help.

  5. #5
    Maren Hachmann Maren Hachmann @Moini

    Yes, that is to be expected. The extension only works with current Inkscape versions (i.e. 1.0 and higher). Use the old version of it with the complex installation (linked from the description) if you really need it on 0.92.5.

  6. #6
    Maren Hachmann Maren Hachmann @Moini

    (if I may ask... why would you need to wait for 1.0 and higher? There are packages available for all operating systems.)

Inkscape Inkscape.org Inkscape Forum Beyond the Basics Best method for diagonal hatching -- what is the "hatches.svg" file for?