Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

So I'm getting a little confused with radii in Inkscape. For quite a while I thought that this:

Path with manual radius

was the same as this:

Rectangle with radius

... But it turns out that overlaying them on top of one another reveals that they are different:

Comparison

(where the red is the rectangle and the blue is the path)

Further analysis reveals that (after converting the rectangle to a path) the handles are in weird locations:

Weird...

So my question is, is it possible to create accurate border radii without the use of the Rectangle tool (where the radius is the same in all angles)? Or must I always rely on it to give me truly accurate results? And also does anyone have an explanation as to why the handles are where they are?

share|improve this question
    
The handles look fine. They're both equidistant from their respective anchors so I don't see a problem there. –  Mr E. Upvoter May 27 at 10:34
    
I would have expected them to be 2px away from their anchors, not ~2.2px –  Marco Scannadinari May 27 at 10:44
    
Ahh I see. I only just noticed that you're talking about inkscape as well. Can you show the anchors for the path your aiming for - the blue shape. Anyway, my amatuer-at-inkscape guess is that maybe the bezier curves are messing up a tad because they aren't perfect math. That's a stab in the dark though. –  Mr E. Upvoter May 27 at 11:03
    
Here: imgur.com/7GPwAaV? Anyway, it seems that its a lot more complex than it seems - whizkidtech.redprince.net/bezier/circle/kappa –  Marco Scannadinari May 27 at 11:50
    
well you can do the coefficient fit yourself but the length of the tangents can be approximated as being 1/3 of the distance between points away in tangent direction. Please note a bezier can not make a perfect circle, so its allways an approximation. –  joojaa May 27 at 16:15

1 Answer 1

up vote 2 down vote accepted

Rounding error at low pixel rates

Especially when drawing in the low pixel range there always is a considerable rounding error which then will become visible.

In the example below I drawed a circle with 4 px radius (grey), a rectangle with 4 px radius reounded corners (black), and a rectancle where the rounded corners were manually made from circles with a 4 px radius (see workaround below).

Values were carefully adjusted from the toolbar to exactly be of a radius 4.000 px). Still, we can see that the rounded rectangle is not perfect:

enter image description here

Draw at higher pixel rates for precision

As soon as we start working at a higher pixel rate (below the red circle has a radius of 40 pixel), the rounded corner of the rectangle will match the exact radius of 40 pixel much better:

enter image description here

Workaround for low pixel rates

In case we need the higher precision at low pixel rate drawings we cannot use the predefined rounded rectangle tool. We may then have to build our shapes manually, e.g. from a base circle:

  1. Transform circle to Bezier path (Path > Object to Path):

    enter image description here

  2. Select all nodes to Break path at selected nodes enter image description here

  3. Select a segment and move it to the desired position.

    enter image description here

  4. Repeat for all segments.

  5. Select the open nodes to Join selected endnotes with new segment enter image description here

    enter image description here

  6. Repeat for the remainder open segments.

This will give better results at low pixel resolutions (see red line in first example above).

share|improve this answer
    
Not too sure its a rounding error - probably just incorrect handle placements on my part, as seen in the question. But the second part of your answer is useful. –  Marco Scannadinari May 29 at 12:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.