Re: [csswg-drafts] [css-shapes-2] `curve to` keyword `using` seems a bit off (#10649)

> > Not many people get involved in the shape() discussion on the calls anyway.
> 
> I think that'll depend somewhat on who you get involved (e.g. @LeaVerou cares a lot about this stuff and @SebastianZ and @kizu pay a lot of attention to syntax);

Thank you for pointing me at this issue, @fantasai! While this issue initially was discussing one keyword, it seems to have turned into a more general discussion about `shape()`s grammar. Please let me know if I am wrong about that assumption and that discussion should happen in another issue! Though for now I'll provide my feedback on this here.

Disclaimer: So far I wasn't much involved regarding `shape()`, so I might be wrong about some assumptions.
Though looking at the grammar, I think the bracketing between the `to` and `by` parts and the spacing are a bit off and the question mark modifiers are unnecessary in the arc command. Also, the wording regarding the control points should be consistent.
Besides that general feedback on the syntax, I have to say it wasn't clear at all from a first reading that the `with` keyword is meant to indicate the control point(s). And the meaning of the `start`, `end`, and `origin` keywords is also not clear to me yet.
And it's also confusing that `<to-control-point>` can be a `<relative-control-point>`, as the `to` keyword always indicates an _absolute_ point, right?
Also, is it really valid to have multple `close` commands an that they can appear in the middle of the command list and not just at the end?

> * There's no way to use positions in hline or vline but maybe we should allow vline to bottom ? Not sure how to write that grammar.

Questions is, what should be allowed? As I understand it, all horizontal keywords for `hline` and all vertical ones for `vline.

> Also I'd recommend dropping the `<by-to>` production since it's only used once and the expansion is almost as short.

In addition to that, I'd split the `to` and `by` productions. While they can syntactically be combined, they have different semantic meaning. So it makes sense to separate them.

Considering all the above, my syntax approach is

```
shape() = shape( <'fill-rule'>? from <coordinate-pair>, <shape-command># )

<shape-command> = <move-command> | <line-command> | <horizontal-line-command> |
                  <vertical-line-command> | <curve-command> | <smooth-command> | <arc-command> | close

<coordinate-pair> = <length-percentage>{2}
<relative-control-point> = <coordinate-pair> [ from [ start | end | origin ] ]?
<to-control-point> = [ <position> | <relative-control-point> ]

<move-command> = move [ to <position> | by <coordinate-pair> ]
<line-command> = line [ to <position> | by <coordinate-pair> ]
<horizontal-line-command> = hline [ to [ <length-percentage> | left | center | right | x-start | x-end ] | by <length-percentage> ]
<vertical-line-command> = vline [ to [ <length-percentage> | top | center | bottom | y-start | y-end ] | by <length-percentage> ]
<curve-command> = curve [ to <position> with <to-control-point> [ / <to-control-point> ]?
                        | by <coordinate-pair> with <relative-control-point> [ / <relative-control-point> ]? ]
<smooth-command> = smooth [ to <position> [ with <to-control-point> ]?
                          | by <coordinate-pair> [ with <relative-control-point> ]? ]
<arc-command> = arc [ to <position> | by <coordinate-pair> ]
                of <length-percentage>{1,2} [ <arc-sweep> || <arc-size> || rotate <angle> ]
```

Sebastian

-- 
GitHub Notification of comment by SebastianZ
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10649#issuecomment-2425269336 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Sunday, 20 October 2024 22:47:04 UTC