W3C home > Mailing lists > Public > www-svg@w3.org > November 2012

Re: marker-pattern syntax

From: Dirk Schulze <dschulze@adobe.com>
Date: Tue, 27 Nov 2012 08:54:01 -0800
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: SVG public list <www-svg@w3.org>
Message-ID: <916670BE-2423-41DB-BEC8-DC5CB8011392@adobe.com>
Tab, Cameron and I had a discussion about the syntax of 'marker', 'marker-pattern' and 'marker-segment' on IRC yesterday[1].

Tabs proposal is the following:

	marker-pattern: [ [ segment | path ] <distance>? <marker-instance> [ <distance> <marker-instance>? ]* ]#

The first <distance> would be an optional offset of the marker-pattern (similar to the offset on 'stroke-dasharray').

This would combine marker-pattern and marker-segment and is easy to integrate into the current marker syntax (which is underspecified in SVG 1.1). It allow the same syntax for marker-segments as for marker-patterns. The behavior is similar, with some exceptions: For segment, he marker repeat starts on every segment again; relative values are resolved according to the segment length, instead of the path length.

I don't really care about the new keywords and would also be fine to not make 'marker' a shorthand at all and keep 'marker-pattern' and 'marker-segment' separate.

Here some examples and my understanding of the syntax(- is the stroke; # is marker m1, O is marker m2):

	marker-pattern: path url(#m1) 20px;
	#--#--#--#….

	marker-pattern: path 10px url(#m1) 20px;
	-#--#--#--#….

	marker-pattern: path 10px url(#m1) 20px 50px;
	-#--#-----#--#-----#--#….

	marker-pattern: path 10px url(#m1) 20px url(#m2) 50px;
	-#--#-----O--#-----O--#….

	marker-pattern: path 10px url(#m1) 20px url(#m2) 50px 10px;
	-#--#-----O-O--#-----O-O--#….

It would also be possible to draw patterns with a specific paint order, which will cause overlapping markers:

	marker-pattern: path 10px url(#m1) 20px, url(#m2) 30px;
	-#--#--#--#--#--#...
	O---O---O---O---O…
m2 would always be drawn on top of m1 (or the other way around, this is up to the specification).

Special case, no repeat:

	marker-pattern: path 50px url(#m1);
	-----#----------------…..

	marker-pattern: path 50px url(#m1), 60px url(#m2);
	-----#O---------------…..

The syntax and behavior for segment is the same, just that it starts again on every segment.

I would like to know if we can agree on the general idea?

Greetings,
Dirk


[1] http://logs.csswg.org/irc.w3.org/css/?date=2012-11-26

On Nov 26, 2012, at 4:15 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

> On Mon, Nov 26, 2012 at 4:07 PM, Dirk Schulze <dschulze@adobe.com> wrote:
>> I would disagree. I think it is totally confusing that it starts with a distance. but even if we go this way: it means you can just add one distance per <url>, after that you need to respecify it. Which is… a lot of code. It also means that you can not specify different markers with different repeatings in different contexts, you are always bound to one pattern, and can't specify independent patterns as well, or need to continue listing the urls until the frequencies of the two different patterns come together. Just see the following two patterns as example:
>> 
>> -------------------#-------------------#-------------------#-------------------#-------------------#-------------------#-------------------#-------------------#-------------------#
>> --------O--------O--------O--------O--------O--------O--------O--------O--------O--------O--------O--------O--------O--------O--------O--------O--------O--------O--------O--------O
>> 
>> These are two marker patterns that you want to apply on a path. I wrote the whole sequence until both patterns start on the same peak again. With your proposal it would be:
>> 
>> 9px url(#m2), 18px url(#m2), 20px url(#m1), 27px url(#m2), 36px url(#m2), 40px url(#m1), 45px url(#m2), 54px url(#m2), 60px url(#m1), 63px url(#m2), 72px url(#m2), 80px url(#m1), 81px url(#m2), 90px url(#m2), 99px url(#m2), 100px url(#m1), 108px url(#m2), 117px url(#m2), 120px url(#m1), 126px url(#m2), 135px url(#m2), 140px url(#m1), 144px url(#m2), 153px url(#m2), 160px url(#m1), 162px url(#m2), 171px url(#m2), 180px url(#m1), 180px url(#m2)
>> 
>> In comparison to:
>> 
>> url(#m1) 20px url(#m2) 9px
> 
> No, you didn't read my grammar correctly, nor my additional
> explanations where I said that the ability to set up independent
> marker tracks seems useful.  In my proposal, you'd write it as:
> 
> marker-pattern: url(#m1) 20px, url(#m2) 9px;
> 
> If you think that looks exactly like yours (except there's a comma
> separating the separate marker tracks), you're right!  I think my
> proposal mixes the best of your proposal and the current grammar.  It
> lets you mix multiple markers in a single track, *and* it lets you do
> independent tracks.
> 
> ~TJ
Received on Tuesday, 27 November 2012 16:54:34 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:53 GMT