Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-shapes-2] Specify the grammar for shape() #11207

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

noamr
Copy link
Collaborator

@noamr noamr commented Nov 13, 2024

grammar changes:

  • <<position>> can be used instead of an absolute point
  • The relevant <<position>>'s dimension can be used for hline/vline
  • Since keywords define the different components, order of components is flexible
  • with is used for curve control points
  • Two curve control points are separated by /
  • Relative control points can be relative to segment-start/segment-end/reference-box, defaulting to segment start.

Resolution: #10649 (comment)

Closes #10649
Closes #10666

[css-spec-shortname-1] Brief description which should also include the #issuenum-or-URL and/or link to relevant CSSWG minutes.

Copy the above line into the Title and replace with the relevant details. Fill in any additional details here. See https://github.com/w3c/csswg-drafts/blob/master/CONTRIBUTING.md for more info.

- <<position>> can be used instead of an absolute point.
- One of a <<position>>'s dimension can be used for hline/vline
- Since keywords define the different components, order of components is flexible.

Curves:
- `with` is used for control points
- Two control points are separated by /
- Relative control points can be relative to segment-start/segment-end/reference-box

Resolution: w3c#10649 (comment)

Closes w3c#10649
Closes w3c#10666
are relative to the top-left corner of the [=reference box=],
while ''by'' indicates that the <<coordinate-pair>>s
while <css>by</css> indicates that the <<coordinate-pair>>s
are relative to the command's starting point.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer true when from start / from end are used. There probably needs to be a new paragraph that explains how control points are resolved, or a "see below for details".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right... There is a paragraph for control points, I'll refer to that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use ''shape()/by'' for the markup. I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

css-shapes-2/Overview.bs Outdated Show resolved Hide resolved
css-shapes-2/Overview.bs Outdated Show resolved Hide resolved
css-shapes-2/Overview.bs Outdated Show resolved Hide resolved
css-shapes-2/Overview.bs Outdated Show resolved Hide resolved
&& <<arc-sweep>>? && <<arc-size>>? && [rotate <<angle>>]?

<<command-end-point>> = [ to <<position>> | by <<coordinate-pair>> ]
<<control-point>> = [ <<position>> | <<relative-control-point>> ]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When implementing this, I mentioned this to @smfr, and he didn't quite agree, but I thought I would bring it to a slightly larger audience.

While generally I don't really see the benefit in disallowing to be used for by (since is really just sugar for [ ], but if the distinction is going to be made, I think the grammar can be a bit more friendly:

<control-point> = [ <position> | <relative-control-point> ]

with one like so:

<absolute-control-point> = <position> [ from [ start | end | origin ] ]?

or, if you dislike the duplication, of the from section,

<control-point-from> = [ from [ start | end | origin ] ]
<absolute-control-point> = <position> <control-point-from>?
<relative-control-point> = <coordinate-pair> <control-point-from>?

This allows a user who is already using an absolute control point, for example like so:

... curve to center center with top left ...

who decides that with top left (aka with 0% 0%) should really be with top left from start to do so. In the current grammar, they have to translate their top left to percentage form and write out with 0% 0% from start.

(doing this also removes a slightly annoying, though manageable, ambiguity in the grammar when parsing <<control-point> since its not clear if "10% 10%" should match <position> or <coordinate-pair>.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When implementing this, I mentioned this to @smfr, and he didn't quite agree, but I thought I would bring it to a slightly larger audience.

While generally I don't really see the benefit in disallowing to be used for by (since is really just sugar for [ ], but if the distinction is going to be made, I think the grammar can be a bit more friendly:

<control-point> = [ <position> | <relative-control-point> ]

with one like so:

<absolute-control-point> = <position> [ from [ start | end | origin ] ]?

or, if you dislike the duplication, of the from section,

<control-point-from> = [ from [ start | end | origin ] ]
<absolute-control-point> = <position> <control-point-from>?
<relative-control-point> = <coordinate-pair> <control-point-from>?

This allows to bottom left from end, how would you interpret that?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As identical to ‘to 100% 0% from end’?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As identical to ‘to 100% 0% from end’?

Ah so like transpose the reference rect to the start/end point... not sure it's a useful box for positioning, might create more confusion than usefulness.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More confusing than the fact that ‘to 100% 0% from end’ is valid and ‘to bottom left’ is valid but not the merged form?

Mostly the point I am trying to make is that treating as something other than syntax sugar for two s seems undesirable. But changing this later is also non-breaking as far I can tell, so I really don’t want to push this any further than I have.

Copy link
Collaborator Author

@noamr noamr Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More confusing than the fact that ‘to 100% 0% from end’ is valid and ‘to bottom left’ is valid but not the merged form?

to 0 100% from end is not valid, only with 0 100% from end or with 10px 220px / 100% 0% from end, the from start|end|origin syntax is only for curve control points.

I read with bottom left as a shorthand for with 0 100% from origin, so expanding it to with 0 100% from origin from end is indeed confusing.

Mostly the point I am trying to make is that treating as something other than syntax sugar for two s seems undesirable. But changing this later is also non-breaking as far I can tell, so I really don’t want to push this any further than I have.

Sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants