-
Notifications
You must be signed in to change notification settings - Fork 23k
Document CSS shape() relative control points and add related Fx146 rel notes #42132
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
base: main
Are you sure you want to change the base?
Document CSS shape() relative control points and add related Fx146 rel notes #42132
Conversation
|
Preview URLs
Flaws (183)Note! 2 documents with no flaws that don't need to be listed. 🎉 URL:
External URLs (1)URL:
|
dipikabh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @chrisdavidmills! It's looking really good.
Added a few suggestions for clarifying and simplifying some text. I can take another look after your updates.
Agree - BCD looks good as is.
|
|
||
| #### Relative control points in CSS `shape()` curve commands | ||
|
|
||
| When specifying a [`<curve-command>`](/en-US/docs/Web/CSS/Reference/Values/basic-shape/shape#curve-command) or [`<smooth-command>`](/en-US/docs/Web/CSS/Reference/Values/basic-shape/shape#smooth-command) in a CSS `shape()` function, [`<relative-control-point>`]()s can be used to specify curve control points that are positioned relative to the start point of the current command, end point of the current command, or the top-left (origin) point of the container the shape is being drawn inside. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could split this long sentence. Also turning it into active voice might help. How about:
| When specifying a [`<curve-command>`](/en-US/docs/Web/CSS/Reference/Values/basic-shape/shape#curve-command) or [`<smooth-command>`](/en-US/docs/Web/CSS/Reference/Values/basic-shape/shape#smooth-command) in a CSS `shape()` function, [`<relative-control-point>`]()s can be used to specify curve control points that are positioned relative to the start point of the current command, end point of the current command, or the top-left (origin) point of the container the shape is being drawn inside. | |
| You can use [`<relative-control-point>`](/en-US/docs/Web/CSS/Reference/Values/basic-shape/shape#relative-control-point) values when specifying a [`<curve-command>`](/en-US/docs/Web/CSS/Reference/Values/basic-shape/shape#curve-command) or [`<smooth-command>`](/en-US/docs/Web/CSS/Reference/Values/basic-shape/shape#smooth-command) in a CSS `shape()` function. These values let you specify control points that are positioned relative to the start or end point of the current command, or relative to the origin (top-left) of the container the shape is being drawn inside. |
|
|
||
| ### Symmetrical `letter-spacing` | ||
|
|
||
| The CSS {{cssxref("letter-spacing")}} property now splits the specified letter spacing evenly on both sides of each character. This is unlike the current behavior where spacing is added primarily to one side. This approach can improve text spacing, especially in mixed-directional text [Firefox bug 1891446](https://bugzil.la/1891446). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to your update, spotted this tiny issue from earlier that could be fixed (parenthesis around the firefox bug):
| The CSS {{cssxref("letter-spacing")}} property now splits the specified letter spacing evenly on both sides of each character. This is unlike the current behavior where spacing is added primarily to one side. This approach can improve text spacing, especially in mixed-directional text. ([Firefox bug 1891446](https://bugzil.la/1891446)). |
|
|
||
| - **Relative control points in CSS `shape()` curve commands**: `layout.css.basic-shape-shape.enabled` | ||
|
|
||
| When specifying a [`<curve-command>`](/en-US/docs/Web/CSS/Reference/Values/basic-shape/shape#curve-command) or [`<smooth-command>`](/en-US/docs/Web/CSS/Reference/Values/basic-shape/shape#smooth-command) in a CSS [`shape()`](/en-US/docs/Web/CSS/Reference/Values/basic-shape/shape) function, [`<relative-control-point>`]()s can be used to specify curve control points that are positioned relative to the start point of the current command, end point of the current command, or the top-left (origin) point of the container the shape is being drawn inside. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same updates can be applied here
| - : Specifies a list of one or more comma-separated commands that define the shape, using syntax similar to [SVG path commands](/en-US/docs/Web/SVG/Reference/Attribute/d#path_commands). Commands include `<move-command>`, `<line-command>`, `<hv-line-command>`, `<curve-command>`, `<smooth-command>`, `<arc-command>`, and `close`. Each command's starting point is the previous command's ending point, with the first point of the shape defined by the [`from <coordinate-pair>`](#from_coordinate-pair) parameter. | ||
|
|
||
| The syntax of most shape commands is a keyword providing a directive, such as `move` or `line`, followed by the `by` or `to` keyword, and a set of coordinates. | ||
| #### Shape commands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for collecting all this related content under a section
| - If only a single `<control-point>` is provided, the command draws a [quadratic Bézier curve](/en-US/docs/Web/SVG/Reference/Attribute/d#quadratic_bézier_curve), which is defined by three points (the start point, control point, and end point). | ||
| - If two `<control-point>` values are provided, the command draws a cubic Bézier curve, which is defined by four points (the start point, two control points, and the end point). | ||
|
|
||
| Valid values for the `<end-point>` component: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Valid values for the `<end-point>` component: | |
| Valid values for `<end-point>` include: |
| - : The control point is relative to the the top-left (origin) point of the container the shape is being drawn inside. | ||
|
|
||
| - `<smooth-command>` | ||
| - : Specified as `smooth [by | to] <end-point> [with <control-point>]`. This command adds a smooth [Bézier curve command](/en-US/docs/Web/SVG/Reference/Attribute/d#cubic_bézier_curve) to the list of shape commands. The `by` or `to` keyword determines whether the ending point of the curve, specified by the `<end-point>`, is relative or absolute, respectively. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - : Specified as `smooth [by | to] <end-point> [with <control-point>]`. This command adds a smooth [Bézier curve command](/en-US/docs/Web/SVG/Reference/Attribute/d#cubic_bézier_curve) to the list of shape commands. The `by` or `to` keyword determines whether the ending point of the curve, specified by the `<end-point>`, is relative or absolute, respectively. | |
| - : Specified as `smooth [by | to] <end-point> [with <control-point>]`. This command adds a smooth [Bézier curve command](/en-US/docs/Web/SVG/Reference/Attribute/d#cubic_bézier_curve) to the list of shape commands. The `by` or `to` keyword determines whether the ending point of the curve, specified by the `<end-point>`, is relative or absolute. |
|
|
||
| {{EmbedLiveSample('Using shape() to define the visible part of an element', '100%', 300)}} | ||
|
|
||
| ### Curve examples with relative control points |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to make it similar in style to other example headings
| ### Curve examples with relative control points | |
| ### Using `shape()` to draw curves with relative control points |
|
|
||
| ### Curve examples with relative control points | ||
|
|
||
| This example also uses {{cssxref("clip-path")}} to create different shapes for the clipping region of different elements. The shapes are specified using a combination of [`<curve-command>`](#curve-command) and [`<smooth-command>`](#smooth-command) , with [`<relative-control-point>`](#relative-control-point) values used for the control points. Note how some of the control points are relative to the start of the current curve, some are relative to the end of the current curve, and some are relative to the origin of the containing box. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of the "Note" sentence, can we add some more details to explain the three curves (similar to the description in other examples on the page)
| This example also uses {{cssxref("clip-path")}} to create different shapes for the clipping region of different elements. The shapes are specified using a combination of [`<curve-command>`](#curve-command) and [`<smooth-command>`](#smooth-command) , with [`<relative-control-point>`](#relative-control-point) values used for the control points. Note how some of the control points are relative to the start of the current curve, some are relative to the end of the current curve, and some are relative to the origin of the containing box. | |
| Like previous examples, this example also uses {{cssxref("clip-path")}} to create different shapes for the clipping regions of the elements. The shapes are specified using a combination of [`<curve-command>`](#curve-command) and [`<smooth-command>`](#smooth-command), and the control points are specified using [`<relative-control-point>`](#relative-control-point). | |
| The first shape (`shape1`) uses control points that are relative to the start of the curve... |
| <div id="three"></div> | ||
| ``` | ||
|
|
||
| ```css hidden live-sample___relative-control-points |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add the @supports code to display the message when shape() is not supported?
| <div id="one"></div> | ||
| <div id="two"></div> | ||
| <div id="three"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for consistency with other examples on this page, can we call these shape1, shape2, and shape3?
|
This pull request has merge conflicts that must be resolved before it can be merged. |
Description
Firefox 146 adds support for CSS
shape()relative control points, as used in<curve-command>and<smooth-command>commands, behind thelayout.css.basic-shape-shape.enabledpref. See https://bugzilla.mozilla.org/show_bug.cgi?id=1921501, and in particular, this comment for some useful details.This PR:
shape()function reference page to improve the<curve-command>and<smooth-command>descriptions (making them easier to understand and adding details) and add some working examples.Some notes:
Motivation
Additional details
Related issues and pull requests