- From: Jeremie Patonnier via GitHub <sysbot+gh@w3.org>
- Date: Mon, 23 Mar 2020 09:34:55 +0000
- To: public-svg-issues@w3.org
> Explicit commands are better than implicit ones. I slightly disagree on this. Implicit can be helpful for both authors and implementers **if the behavior is well defined.** Defining such behavior is the whole point of that conversation 😉 > Your suggestion here is that a path fragment like L1,1 should have an implied pre-pended M0,0 but consider the alternative of having half a dozen path fragments and just putting them together with having a null-start position implied. You could see how the L1,1 fragment is easily represented by that and that you could put that fragment as part of a string of path fragments and it would properly have a 1:1 implied representation between path_d fragment and path fragment. That's a very good point. AFAIK, SVG does not define sub-paths or path fragments formally. Such a path fragment could be any list of valid path commands. The current path grammar only define a full valid path that will be render-able. (hence, it must start with an `M|m` command). In essence, it formally prevents the ability to parse something like a standalone `l1,1 m2,2 l3,3` path fragments. So maybe, rather than just relaxing the current path grammar, we need to formally define what is path fragment and how to use it. I would tend to ask for the following: 1. Relax the path grammar by removing that mandatory first `M` command and state that this is the definition of _a valid path fragment_ 2. State that a complete render-able path is a path fragment starting with an `M` command follow by 0 to N valid path fragments. Some may argue that this is exactly what the current spec allows. IMO this is different in the sens that it move the error management regarding render-able path **out of the parser**. Checking if the path start with an `M` command shouldn't be done at the parser level if we want to allow path fragment to formally exist. At the second we have formally defined render-able path versus path fragments, it opens the gate to reusable/shareable path fragments in SVG which would be an awesome features (especially for cartography). I would love to be able to do something like this: ```xml <svg viewBox="0,0,100,100> <path id="myFragment" d="C100,100 0,0 0,50" /><!-- Not rendered --> <path d="M0,50 V0 H100 V50 #myFragment z" /><!-- render with the path fragment defined earlier --> <path d="M0,50 V100 H100 V50 #myFragment z" /><!-- render with the path fragment defined earlier --> ``` The condition for this is to make sure that a path fragment isn't an error at the parsing level. So to conclude: The fact that a path needs to start with an M command to be render should not trigger a parsing error. -- GitHub Notification of comment by JeremiePat Please view or discuss this issue at https://github.com/w3c/svgwg/issues/780#issuecomment-602483012 using your GitHub account
Received on Monday, 23 March 2020 09:34:57 UTC