On Thu, 2012-08-23 at 10:52 -0700, mathog wrote:
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:
- 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.)
Currently, markers, patterns, etc. inherit at the point of their creation and not where they are referenced. SVG 2 will allow markers to match the color of the stroke (or fill). This mechanism should also work for patterns.
- 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[]; ?
Not that I know of. SVG 2 will add hatch lines that will solve the problem of visible discontinuities. (They are also required by engravers that use SVG for their input.)
Thanks,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech
Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel