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

Added CSS shape-rendering property #35228

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11709,7 +11709,6 @@
/en-US/docs/Web/CSS/scroll /en-US/docs/Web/CSS/overflow
/en-US/docs/Web/CSS/scrollbar-track-color /en-US/docs/Web/CSS/scrollbar-color
/en-US/docs/Web/CSS/shape-box /en-US/docs/Web/CSS/shape-outside
/en-US/docs/Web/CSS/shape-rendering /en-US/docs/Web/SVG/Attribute/shape-rendering
/en-US/docs/Web/CSS/sign() /en-US/docs/Web/CSS/sign
/en-US/docs/Web/CSS/sign_function /en-US/docs/Web/CSS/sign
/en-US/docs/Web/CSS/single-transition-timing-function /en-US/docs/Web/CSS/easing-function
Expand Down
94 changes: 94 additions & 0 deletions files/en-us/web/css/shape-rendering/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
title: shape-rendering
slug: Web/CSS/shape-rendering
page-type: css-property
browser-compat: css.properties.shape-rendering
---

{{CSSRef}}

The **`shape-rendering`** [CSS](/en-US/docs/Web/CSS) property provides hints to the renderer about what tradeoffs to make when rendering shapes like paths, circles, or rectangles.
It only has an effect on the {{SVGElement("circle")}}, {{SVGElement("ellipse")}}, {{SVGElement("line")}}, {{SVGElement("path")}}, {{SVGElement("polygon")}}, {{SVGElement("polyline")}}, and {{SVGElement("rect")}} elements. If explicitly declared, the value of the CSS property overrides the any values of the element's {{SVGAttr("shape-rendering")}} attribute.

## Syntax

```css
shape-rendering: auto;
shape-rendering: crispEdges;
shape-rendering: geometricPrecision;
shape-rendering: optimizeSpeed;

/* Global values */
shape-rendering: inherit;
shape-rendering: initial;
shape-rendering: revert;
shape-rendering: revert-layer;
shape-rendering: unset;
```

### Values

The {{cssxref("length")}} and {{cssxref("percentage")}} values denote the horizontal center of the circle or ellipse.

- `auto`
- : This value directs the user agents to make tradeoffs in order to balance speed, edge crispness, and geometric precision, with geometric precision given more importance than speed and edge crispness.
- `crispEdges`
- : This value directs the user agent to emphasize edge contrast over geometric precision or rendering speed. The final rendering is likely to skip techniques such as anti-aliasing. It may also adjust line positions and line widths in order to align edges with device pixels.
- `geometricPrecision`
- : This value directs the user agent to emphasize geometric precision over speed or crisp edges. The final rendering may involve techniques such as anti-aliasing.
- `optimizeSpeed`
- : This value directs the user agent to emphasize rendering speed over geometric precision or edge crispness. The final rendering is likely to skip techniques such as anti-aliasing.

## Formal definition

{{CSSInfo}}
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here about missing CSSInfo data. Otherwise looking great

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per Josh-Cena’s comment in 35107, the macro should stay even if currently broken. (This is the case on several other CSS pages, in fact.) I can look into adding the information to mdn/data when I return from holiday, but in the meantime I believe this can be merged.

Copy link
Member

Choose a reason for hiding this comment

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

OK got it. I've opened a tracker in mdn/data so we don't forget


## Formal syntax

{{csssyntax}}

## Example

To show the different renderings, we create a set of four ellipses of equal size and shape.

```html
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 120">
<ellipse cx="50" cy="60" rx="40" ry="60" />
<ellipse cx="150" cy="60" rx="40" ry="60" />
<ellipse cx="250" cy="60" rx="40" ry="60" />
<ellipse cx="350" cy="60" rx="40" ry="60" />
</svg>
```

We then apply the four values of `shape-rendering`, one per ellipse.

```css
ellipse:nth-of-type(1) {
shape-rendering: crispEdges;
}
ellipse:nth-of-type(2) {
shape-rendering: geometricPrecision;
}
ellipse:nth-of-type(3) {
shape-rendering: optimizeSpeed;
}
ellipse:nth-of-type(4) {
shape-rendering: auto;
}
```

The resulting SVG is shown here. The first and third ellipses (counting from left to right) are more likely to show jagged edges, whereas the second should have a smoother appearance. The fourth and last ellipse's appearance will be dictated by the specific tradeoffs made by the user agent you use to view the example.

{{EmbedLiveSample("Example", "400", "240")}}

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- SVG {{SVGAttr("shape-rendering")}} attribute
6 changes: 5 additions & 1 deletion files/en-us/web/svg/attribute/shape-rendering/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ browser-compat: svg.global_attributes.shape-rendering
The **`shape-rendering`** attribute provides hints to the renderer about what tradeoffs to make when rendering shapes like paths, circles, or rectangles.

> [!NOTE]
> As a presentation attribute, `shape-rendering` can be used as a CSS property.
> As a presentation attribute, `shape-rendering` can be used as a CSS property. See {{cssxref('shape-rendering')}} for more.

You can use this attribute with the following SVG elements:

Expand Down Expand Up @@ -79,3 +79,7 @@ svg {
## Browser compatibility

{{Compat}}

## See also

- CSS {{cssxref('shape-rendering')}} property