question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RequiresSmoothRendering is always false for an SvgRectangle if CornerRadiusX and CornerRadiusY are 0

See original GitHub issue

Description

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
Rectangles with corner radius rectangles-rounded

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:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mrbean-bremencommented, Mar 22, 2022

Ok, I did a few tests, and Chrome, FireFox and Edge agree on the handling (IE seems not to handle shape-rendering). If shape-rendering is set to auto or geometricPrecision, they use anti-aliasing for the rectangles, if set to optimizeSpeed or crispEdges 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 for geometricPrecision, and remove the overload for Rectangle. Any thoughts?

0reactions
mrbean-bremencommented, Apr 7, 2022

Consider fixed, as it now bahaves like in browsers, and the standard is not very specific about the implementation.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found