
I have a couple of questions related to SVG patterns.
First some background. After a bit of experimenting I came up with the following patterns to match the standard hatch patterns available in the EMF file type. Notice that the stroke color is hard coded. The translate 6 lines are needed to prevent visible discontinuities in the pattern for diagonal lines. (Not needed for the diagonal cross hatch because the perpendicular lines fill in each other's discontinuities.)
<pattern id="EMFhatch0" patternUnits="userSpaceOnUse" width="6" height="6" x="0" y="0"
<path d="M 0 0 6 0" style="fill:none;stroke:black" /> </pattern> <pattern id="EMFhatch1" patternUnits="userSpaceOnUse" width="6" height="6" x="0" y="0"
<path d="M 0 0 0 6" style="fill:none;stroke:black" /> </pattern> <pattern id="EMFhatch2" patternUnits="userSpaceOnUse" width="6" height="6" x="0" y="0" viewBox="0 0 6 6" preserveAspectRatio="none" > <line x1="-1" y1="-1" x2="7" y2="7" stroke="black" id="subEMFhatch2"/> <use xlink:href="#subEMFhatch2" transform="translate(6,0)"/> <use xlink:href="#subEMFhatch2" transform="translate(-6,0)"/> </pattern> <pattern id="EMFhatch3" patternUnits="userSpaceOnUse" width="6" height="6" x="0" y="0" viewBox="0 0 6 6" preserveAspectRatio="none" > <line x1="-1" y1="7" x2="7" y2="-1" stroke="black" id="subEMFhatch3"/> <use xlink:href="#subEMFhatch3" transform="translate(6,0)"/> <use xlink:href="#subEMFhatch3" transform="translate(-6,0)"/> </pattern> <pattern id="EMFhatch4" patternUnits="userSpaceOnUse" width="6" height="6" x="0" y="0"
<path d="M 0 0 6 0 M 0 0 0 6" style="fill:none;stroke:black" /> </pattern> <pattern id="EMFhatch5" patternUnits="userSpaceOnUse" width="6" height="6" x="0" y="0" viewBox="0 0 6 6" preserveAspectRatio="none" > <use xlink:href="#subEMFhatch2" transform="translate(0,0)"/> <use xlink:href="#subEMFhatch3" transform="translate(0,0)"/> </pattern>
Questions:
1. Is it possible to inherit or reference the stroke color in the pattern? For instance, this fills a square with the first EMF hatch pattern (horizontal lines): <path style="fill:url(#EMFhatch0); fill-rule:evenodd;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1;" d=" M 149.99595 262.49292 L 172.49535 262.49292 L 172.49535 284.99231 L 149.99595 284.99231 z " />
Stroke in the path style is for the line bounding the square, so it isn't available for the fill to reuse. The "fill" value is used to reference the pattern, so it isn't available either. It would be nice to be able to specify a color other than black for the pattern, other than by having to create a second pattern which differs only in its stroke value. In general SVG allows inheritance, but here the obvious routes are blocked. If this isn't possible I guess it will come down to naming the patterns like "EMFhatch0_FF0000", with the color appended to the name. (This is in order to avoid having multiple defines with different names for the exact same pattern.)
2. Because of the free form way patterns are defined it looks really, really hard to map arbitrary user defined patterns onto the standard set of EMF hatch patterns (or CGM, or any other graphics standard that has a predefined set). Is there anything in inkscape presently along these lines (pseudocode): pattern[i].has_horizontal_lines(); // pattern has horizontal line elements pattern[i].has_vertical_lines[]; pattern[i].has_diagonal_lines[]; pattern[i].has_antidiagonal_lines[]; ?
Thanks,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech