-
Notifications
You must be signed in to change notification settings - Fork 677
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] Allow CSS grammar for path shapes #5674
Comments
Thoroughly agree with this. The lack of units is just about manageable, but the inability to use
I'm presuming spaces are inserted between the tokens, and that numbers are stringified before concatenation. Even if units aren't allowed, this would go a very long way to making it more usable. |
This may actually be solved by: #542 |
Oof, string concat isn't the way to go here. What we've needed for a long while is a CSS-ified grammar for path strings, that takes idents and lengths and such, so it can interoperate with the rest of CSS's value system. I've been meaning to spend time on that for several years, but it's always slipped below the priority line. |
Yea, it feels like it would solve the issue but not in a nice way.
Sounds great! Maybe I'll have time to take a crack at it. |
I'd love to review it. Note that we can be opinionated about this and impose CSS best practices for grammar design, like commas between repeated items and not just any old place, and using keywords rather than |
got it, I'm envisioning it looking more like the other shapes like polygon. |
@tabatkins |
I can go either way! I slightly lean away from the nested-functions approach just because more nesting makes it harder to read and write. I suspect it would be nice to provide the commands as both single-letter (matching existing path strings) and full-word forms. |
Awesome. I'll go with non-nested, allowing both SVG-style and full keywords. |
We can't really do the SVG-style as is because it relies on case sensitivity :) |
That's not necessarily a problem. CSS is generally case-insensitive in the ASCII range, but it's allowed to not be, if it wants. For example, anything specified as a So it would be a slight departure from standard CSS style to make |
Great. The current syntax I have in mind is approximately this:
For the example of a scalable balloon-with-cursor clip, it would look like:
or
or a combination of both. Some doubts I'm contemplating:
|
For what it's worth, I'd prefer to keep the SVG <complex-shape> ::= shape( [
[[horizontal|vertical] [to|by] <<length-percentage>>+] |
[[move|line] [to|by] <coordinate-pair>+] |
[qurve [to|by] [<coordinate-pair> [via <coordinate-pair>]?]+] |
[curve [to|by] [<coordinate-pair> [via <coordinate-pair>{1,2}]?]+] |
[arc [to|by] [<coordinate-pair> [at <<length-percentage>>{1,2}] <<angle>>? large-arc? sweep?]+] |
[close]
]# );
<coordinate-pair> ::= <<length-percentage>>{2}; PS: Replacing curve [to|by] [<coordinate-pair>
[via auto] | ; quadratic
[via <coordinate-pair>] | ; quadratic
[via auto <coordinate-pair>] | ; cubic
[via auto auto] | ; cubic
[via <coordinate-pair>{2}] | ; cubic
; quadratic
]+ |
I can go with
where |
SVG path segments. Fixes w3c#5674
SVG path segments. Fixes w3c#5674
I find the functional notation (move(), line(), etc.) MUCH easier to read that the single letters. I pretty much hate the single letters, and they are not CSSy. Could we have those functions as the outer value, and NOT embed them in another function like shape()? |
It's possible, but not sure how to represent the initial parameters in this case (fill-rule and starting-point). An example in the current PR looks something like the If you remove the
Or if you make it more like
I like how the last one looks, but it also feels like it's inconsistent with the other shapes which have their own functions, which makes |
Is the path constructed in physical coordinate space? Should this new syntax allow for building paths which are writing-direction aware? |
I think that it should be direction-aware by default. It might not even need additional syntax, it's enough to use the existing |
Or maybe even this:
...if it always needs a starting point. I think I would put commas there where it separates the series of drawing instructions, but not after evenodd, which feels more like a separate value part (not one in a series of path parts). I think would be sort of special as a value type that consists of sub-values and functions (a little bit like box-shadow, which might contain a color function), rather than needing to be a function of its own. At least, I would prefer it that way and think it would be simpler and pretty intuitive to write. |
I'm not in favor exploding the shape out, it will not allow additional parameters to clip-path or to anything caller of the different shape functions. I still the current gradient-like proposal the best. Regarding the starting point, look at the PR (#5711). |
Agenda+ to discuss merging the PR in #5711. |
The CSS Working Group just discussed
The full IRC log of that discussion<dael> Topic: [css-shapes] Allow CSS grammar for path shapes<dael> github: https://github.com//issues/5674 <dael> TabAtkins: I've been looking for something like this for a while. SVG path is a little weird. RIght now you have to do path as a string and you can't concat a string it means you can't build path with variables <dael> TabAtkins: User friction thing <dael> TabAtkins: Proposal, not from me, with good syntax converting svg syntax to css friendly version. I really like how it looks. Extensible to logical coordinates. I think this is a nice good approach and I'l like to add to spec <dino> q+ <dael> fantasai: I reviewed the PR and discussion and I think it's a good prop, well specified <astearns> ack fantasai <astearns> ack dino <dael> dino: I left some minor comments, but don't care if they're not addressed. <dael> dino: If one was to animate; this was defined as eq to SVG path so thus if you animate between the svg rules apply and thus you need same number of segments with same type? <dael> TabAtkins: Yeah <dael> dino: Therefore a curve, if a command was curve xy via something if one gave 2 coord and the other 1 they would not animate, right? <dael> dino: THe distinction between quadratic and cubic is number of params, not command type. <dael> dino: Maybe a bit strange curve says where it's going first. But again it's minor. I'll mention it, but I don't care <dael> astearns: And one of the reasons to take the PR is so we can open more issues to make amendments. I assume animations is not defined in PR so we'd unpack in spec. <dael> TabAtkins: Yeah <dael> astearns: dino you mentioned you made comments. I saw one on PR about typo <dael> dino: They're all minor and can be issues after <dael> astearns: Hearing agreement. Objections to merge this PR? <dael> RESOLVED: Merge this PR into next level of Shapes |
Currently, when using shapes in e.g.
clip-path
, some features are only allowed in polygon, and some only in path.So it's currently impossible to create a non-rect polygon that has both rounded corners and relative (or em) coordinates, or custom properties, for example a speech bubble with an arrow.
I suggest one of the following:
polygon()
(easier)path()
(more powerful)The text was updated successfully, but these errors were encountered: