Jun 5, 2009

Round Corners Issue

When drawing a circle with 4 points by bezier curve, the ratio of the handle length to the radius is about 0.5522847 (4 * (sqrt(2) - 1) / 3).

I thought Illustrator's "Round corners" filter (and effect) uses this ratio for the specified "radius". But I was wrong.

I measured length of the handles with a script (at end).
Maybe it uses more simple rule -- multiplying 0.55 by the radius.
Though it may not become a problem most of the time.

Anyway, it uses fixed length of handle for any corner. The corners are rounded, but they are not the arcs of specified radius most of the time.
Is it an useless low-quality tool? At least, it isn't always bad.
Applying it to the slanted rectangle like below, the effect may be as expected.
What if it strictly uses arcs in this case?
Though it is sure that it would be nice if we had that tool.

My script "Round Any Corner" (placed in my alternate site) basically uses same algorithm as above (but the ratio is 0.5522847). Because I think this method creates a neat shape that is suited for design, rather than using arcs. And to be honest, rounding the intersection point of curves by arc is difficult to script for me. Awfully troublesome at least.

It doesn't always creates arcs, and (unfortunately) isn't intended for that purpose.

// measures length of the handles
const FONT_SIZE = 9;
const FONT_NAME = "TimesNewRomanPSMT";
const DIGIT = 4;

var pi = app.activeDocument.selection[0];
var p = pi.pathPoints;
var d;

for( var i = 0; i < p.length; i++ ){
d = dist(p[i].anchor, p[i].rightDirection);
if(d > 0)
drawText( d.toFixed( DIGIT ), p[i].rightDirection);

d = dist(p[i].anchor, p[i].leftDirection);
if(d > 0)
drawText( d.toFixed( DIGIT ), p[i].leftDirection);
}
// -------
function drawText(txt, pos){
with(activeDocument.activeLayer.textFrames.add()){
contents = txt;
with(textRange){
with(characterAttributes){
size = FONT_SIZE;
textFont = textFonts.getByName( FONT_NAME );
}
with(paragraphAttributes){
justification = Justification.CENTER;
}
}
position = [pos[0] - width / 2, pos[1] + height / 2];
}
}
// -------
function dist(p, q){
return Math.sqrt(Math.pow(p[1] - q[1], 2)
+ Math.pow(p[0] - q[0], 2));
}

2 comments:

  1. I love this tool, But i would like to enter the Radius value as mm Millimeters, rather then in points.
    Is there a simple fix for this?

    ReplyDelete
  2. If you mean "Round any corner" script, please download the latest one from
    http://park12.wakwak.com/~shp/lc/et/en_aics_script.html

    It recognizes several units. If you want to use 5 mm for radius, please input "5mm".
    Speaking about the code inside the script, every "mm" input is replaced by "* 2.83464567".

    ReplyDelete