RequiresSmoothRendering is always false for an SvgRectangle if CornerRadiusX and CornerRadiusY are 0
See original GitHub issueDescription
Anti-aliasing is never used for a simple rectangle without rounded corners, but forcing anti-aliasing to be enabled improves the rendering. I do not quite understand the reasoning for the logic in SvgRectangle.
Currently, RequiresSmoothRendering is implemented like this:
protected override bool RequiresSmoothRendering
{
get
{
if (base.RequiresSmoothRendering)
return (CornerRadiusX.Value > 0.0f || CornerRadiusY.Value > 0.0f);
else
return false;
}
}
But this would make more sense to me (no matter what base.RequiresSmoothRendering returns, force it on if corners are rounded):
protected override bool RequiresSmoothRendering
{
get
{
if (!base.RequiresSmoothRendering)
return (CornerRadiusX.Value > 0.0f || CornerRadiusY.Value > 0.0f);
else
return true;
}
}
Example data
SVG | svg-net rendering |
---|---|
Rectangles | |
Rectangles with corner radius |
When the original svg is rendered to a small bitmap the spacing and bottom vertical alignment does not appear to be consistent, but the rendering is improved when anti-aliasing is forced to be on by adding a very small corner radius to the rectangles.
Used Versions
SVG 3.3.0 .NET Framework 4.8
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
`CALayer.cornerRadius` doesn't work if `masksToBounds = ...
If you set masksToBounds = false , cornerRadius will not work. But if you set masksToBounds = true , then shadows won't work....
Read more >Swift Tip: Adding Rounded Corners and Shadows to a ...
The corners will be rounded, but the shadow will be missing. If you set masksToBounds to false, the shadow will appear, but the...
Read more >cornerRadius | Apple Developer Documentation
By default, the corner radius does not apply to the image in the layer's contents property; it applies only to the background color...
Read more >Simple gauge corner radius - Ignition
The arc itself has a cornerRadius property, which result in the rounded corners on the orange arc. But it does not seem to...
Read more >How to set cornerRadius for only some corners
Not every time that we want all corners to be round. To make only specific corners round, you can do one of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I did a few tests, and Chrome, FireFox and Edge agree on the handling (IE seems not to handle
shape-rendering
). Ifshape-rendering
is set toauto
orgeometricPrecision
, they use anti-aliasing for the rectangles, if set tooptimizeSpeed
orcrispEdges
they don’t use it, regardless of rounded edges. The same seems to be true for other shapes. So to conform to these, we would have to change the base implementation to use anti-aliasing also forgeometricPrecision
, and remove the overload forRectangle
. Any thoughts?Consider fixed, as it now bahaves like in browsers, and the standard is not very specific about the implementation.