[svgwg] Verbose SVG for improved human readability

Crissov has just created a new issue for https://github.com/w3c/svgwg:

== Verbose SVG for improved human readability ==
I wish there was a supplementary superset of SVG that made the `rect`, `circle`/`ellipse`, `line`, `polyline` and `polygon` optionally have a number of `p` children. The number of mandatory and optional `p` children varies by element type.

The `p` element is a _point_ or _coordinate_, specified either absolutely by `x` and `y` attributes or relatively by `dx` and `dy` attributes. They all default to `0` initially, but `x` and `y` inherit the computed values of the previous sibling – or cousin in `path` – point. If both, `x` and `dx` or `y` and `dy`, are specified the relative values are added to the absolute ones to give the computed coordinate. 

``` xml
<rect><!-- 1 absolute and 1 relative point -->
 <p x="rect@x" y="rect@y"/>
 <p dx="rect@width" dy="rect@height"/>
 <!-- not sure how corner radii specified with rect@rx and rect@ry should be dealt with -->
</rect>
<rect><!-- 2 absolute points specify two corners -->
 <p x="rect@x" y="rect@y"/>
 <p x="rect@x + rect@width" y="rect@y + rect@height"/>
</rect>

<circle><!-- 2 points: center and on arc, `circle` aliases `ellipse` -->
 <p x="circle@cx" y="circle@cy"/>
 <p dx="circle@r" dy="circle@r"/>
</circle>
<circle>
 <p x="circle@cx" y="circle@cy"/>
 <p dx="circle@r"/>
</circle>
<circle>
 <p x="circle@cx" y="circle@cy"/>
 <p dy="circle@r"/>
</circle>
<ellipse>
 <p x="ellipse@cx" y="ellipse@cy"/>
 <p dx="ellipse@rx" dy="ellipse@ry"/>
</ellipse>

<line>
 <p x="line@x1" y="line@y1"/>
 <p x="line@x2" y="line@y2"/>
</line>
```

I believe a superset syntax like this would make editing by hand, especially reading, easier. The transformations to the legacy syntax are straightforward, but for these elements the argument is probably not convincing enough. It gets handier with elements that support more, i.e. an arbitrary number of points:

``` xml
<polyline><!-- `polyline` aliases `line`, polyline@points: -->
 <p x="" y=""/><!--+-->
 <p dx="" dy=""/><!--+-->
</polyline>
<polygon><!-- polygon@points: -->
 <p x="" y=""/><!--+-->
 <p dx="" dy=""/><!--+-->
</polygon>
```

The `path`  element on the other hand would have an additional layer of intermediate children that specify the drawing method otherwise encoded as a single case-sensitive letter inside its `d` attribute. Making its compact `d` notation more readable and editable is the main motivation for this issue.

``` xml
<path>
 <!-- `moveto` -->
 <move><p x="M1" y="M2"/></move>
 <move><p dx="m1" dy="m2"/></move>
 <!-- `closepath` -->
 <close/><!--Z/z-->
 <!-- `lineto` -->
 <line><p x="L1" y="L2"/><!--+--></line>
 <line><p dx="l1" dy="l2"/><!--+--></line>
 <line><p x="H"/></line>
 <line><p dx="h"/></line>
 <line><p y="V"/></line>
 <line><p dy="v"/></line>
 <!-- cubic Bézier -->
 <curve><p x="C1" y="C2"/><p x="C3" y="C4"/><p x="C5" y="C6"/><!--+--></curve>
 <curve><p dx="c1" dy="c2"/><p dx="c3" dy="c4"/><p dx="c5" dy="c6"/><!--+--></curve>
 <spline><p x="S1" y="S2"/><p x="S3" y="S4"/><!--+--></spline>
 <spline><p dx="s1" dy="s2"/><p dx="s3" dy="s4"/><!--+--></spline>
 <!-- quadratic Bézier -->
 <qurve><p x="Q1" y="Q2"/><!--+--></qurve>
 <qurve><p dx="q1" dy="q2"/><!--+--></qurve>
 <t><p x="T1" y="T2"/><p x="T3" y="T4"/><p x="T5" y="T6"/><!--+--></t>
 <t><p dx="t1" dy="t2"/><p dx="t3" dy="t4"/><p dx="t5" dy="t6"/><!--+--></t>
 <!-- elliptical arc -->
 <arc rotation="A3" large-arc="A4" sweep="A5"><p dx="A1" dy="A2"/><p x="A6" y="A7"/></arc>
 <arc rotation="a3" large-arc="a4" sweep="a5"><p dx="a1" dy="a2"/><p dx="a6" dy="a7"/></arc>
 <!-- Catmull-Rom -->
 <rom><p x="R1" y="R2"/><p x="R3" y="R4"/><!-- --><p dx="R5" dy="R6"/><!--*--></rom>
 <rom><p dx="r1" dy="r2"/><p dx="r3" dy="r4"/><!-- --><p dx="r5" dy="r6"/><!--*--></rom>
 <!-- bearing ? -->
 <bear a="B"/>
 <bear da="b"/>
 <bear><p x="cos(B)" y="sin(B)"/></bear>
 <!-- * -->
</path>
```


Please view or discuss this issue at https://github.com/w3c/svgwg/issues/340 using your GitHub account

Received on Saturday, 12 August 2017 13:58:06 UTC