Controlling Curves in Shapes

When you want to create a shape with rounded corners, you can either apply a rounded corner style or create an arc, depending on how you want the shape to resize. The following figure shows the results of using these methods.

How shapes with different corners resize

How shapes with different corners resize

  1. Rectangle with rounded corners stretches without affecting the curvature of its corners.
  1. Circular arcs might distort the shape when it is resized.
  1. Elliptical arcs resize smoothly with the shape, but the resulting corners might not be what you want.

If you draw a shape with the Pencil, Line, Arc, or Rectangle tool, you can connect the straight portions with an elliptical arc segment. As you stretch a shape, the beginning and ending vertices of a curve generally move in proportion to the stretching. Using arc segments for this purpose can give you more control over the shape, because arc segments don't depend on the line or corner style, and arcs can be controlled with formulas.

An elliptical arc can change its eccentricity to maintain smoothness. A circular arc tries to fit a circle between the beginning and ending vertices, which can result in a bulge or a sharp edge between a curve and a line. To prevent this distortion, you can control the bow of the arc with formulas. Creating a shape with rounded corners in this way ensures that the shape's corners span a set angle, so that the corners resize smoothly.

In this section…

Using Rounded Corner Styles

Understanding Arcs

Converting Line and Arc Segments

Useful Arc Formulas

Using Rounded Corner Styles

When you use the Corner Rounding command on the Format menu, you are applying a rounded style to a line's corners. You can construct the shape with straight line segments, instead of a mixture of lines and arcs. The corner style does not change the shape's geometry, only the way it is drawn on the screen.

A polygon formatted with rounded corners and then resized

A polygon (A) formatted with rounded corners (B), and then resized (C)

Although a shape with a rounded corner style resizes as expected, applying a new line style that specifies different (or no) corner attributes can easily overwrite the rounded corner style. Therefore, you might want to protect the shape's formatting by setting its LockFormat cell to TRUE or guarding the formula in the Rounding cell of its Line Format section. For details about styles, see Chapter 10, Managing Styles, Formats, and Colors.

TOP

Understanding Arcs

A circular arc is**a portion of a circle. An elliptical arc is a portion of an ellipse. An elliptical arc can appear to be circular, because a circle is simply a special case of an ellipse.

The arcs you draw with the Arc tool are always a quarter of an ellipse, and those drawn with the Pencil tool are a portion of a circle. However, both are represented in a Geometry section as elliptical arcs, defined by EllipticalArcTo rows. To obtain a true circular arc, you must change its row type to ArcTo in its Geometry section.

Circular arcs

In a circular arc, the magnitude of the bow is the distance from the midpoint of the chord to the midpoint of the arc, as the following figure shows.

A circular arc

A circular arc

  1. Chord
  1. Control point
  1. Bow

The bow's value is positive if the arc is drawn in the counterclockwise direction; otherwise, it is negative. A selected arc has a control point at the midpoint, which is always located along the perpendicular bisector of the chord. If you try to move the control point with the Pencil tool, the point moves freely, but it always snaps back to a position along the perpendicular bisector.

When you resize a circular arc, you change the radius of the circle of which the arc is a portion. The arc may flatten or bulge—appropriate resizing behavior for a circle, but perhaps not the expected behavior for your shapes. (To resize proportionately, you must use an elliptical arc as described later in this topic.)

Resizing a circular arc

Resizing a circular arc

  1. Dragging the control point changes the bow value of the arc.

By default, all arcs created with the Microsoft® Visio® drawing tools are elliptical arcs. To create a circular arc, you must change the row type in its Geometry section.

To create a circular arc

  1. Select an arc shape on the page. On the Window menu, click Show ShapeSheet.
  1. In the Geometry section, select the LineTo or EllipticalArcTo row that you want to convert to a circular arc.
  1. On the Edit menu, click Change Row Type.
  1. Click ArcTo, and then click OK.

The following table shows what the cells of an ArcTo row represent.

Circular arc representation in the Geometry section

Row

Cell

Value

The row that precedes the ArcTo row

X

The x-coordinate of the begin point of the arc

 

Y

The y-coordinate of the begin point of the arc

ArcTo

X

The x-coordinate of the end point of the arc

 

Y

The y-coordinate of the end point of the arc

 

A

Size of the arc's bow

Elliptical arcs

When stretched, an elliptical arc's eccentricity changes in proportion to the stretching, so the arc maintains a smooth curve. Eccentricity controls how asymmetrical (lopsided) the arc appears.

An elliptical arc

An elliptical arc

  1. Major axis
  1. Minor axis
  1. Control point
  1. Angle

The eccentricity of an arc is the result of dividing its major axis by its minor axis.

In most cases, you'll probably want to use an elliptical arc in your shapes rather than a circular arc, because a circular arc's resizing behavior is constrained by the fact that it must remain circular.

Note In versions of Visio earlier than 2000, an ellipse was represented by two EllipticalArcTo rows. Beginning with Visio 2000, an ellipse is represented by a single Ellipse row.

For details on EllipticalArcTo and Ellipse rows, see the ShapeSheet Reference in the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).

To create an elliptical arc, do one of the following

  • Draw an arc using the Pencil or Arc tool.
  • In its Geometry section, change the row type of the LineTo or an ArcTo row that you want to convert to an elliptical arc to an EllipticalArcTo row.
  • On the drawing page, use the Pencil tool to drag the control point of a straight line. This transforms the line into an elliptical arc.

An elliptical arc's geometry is described in an EllipticalArcTo row, as the following table shows.

Elliptical arc representation in the Geometry section

Row

Cell

Value

The row that precedes EllipticalArcTo

X

The x-coordinate of the begin point of the arc

 

Y

The y-coordinate of the begin point of the arc

EllipticalArcTo

X

The x-position of the end point of the arc

 

Y

The y-position of the end point of the arc

 

A

The x-position of the control point of the arc

 

B

The y-position of the control point of the arc

 

C

Angle of the arc

 

D

Eccentricity of the arc

You can move the control point of an elliptical arc to change the arc's eccentricity. An eccentricity of 1 represents a circular arc, and a value greater or less than 1 represents an arc with more or less eccentricity. For example, in an ellipse that is 2 inches wide and 1 inch tall, each elliptical arc has an eccentricity of 2. In an ellipse that is 1 inch wide and 2 inches tall, each elliptical arc has an eccentricity of 1/2.

To change an elliptical arc's eccentricity

  • Select the Pencil tool, and then press CTRL as you drag the control point to display the eccentricity handles, which you can stretch and rotate.

When you move an arc's eccentricity handles, Visio generates formulas in the C and D cells of the EllipticalArcTo row; these formulas record the current orientation and shape of the elliptical arc. If a shape with elliptical arcs is stretched, Visio changes the eccentricity and angle of the arcs, if necessary, so that the arcs resize consistently with the rest of the shape.

TOP

Converting Line and Arc Segments

You can convert a line or elliptical arc to a circular arc segment by changing the type of the corresponding row in the Geometry section. You can also change line and arc segments using various drawing tools.

To change a line or elliptical arc to a circular arc in the ShapeSheet window

  • Right-click the LineTo or EllipticalArcTo row in the Geometry section that represents the segment you want to change. On the shortcut menu, click Change Row Type, and then click ArcTo. Or, select the row, click Change Row Type on the Edit menu, and then click ArcTo.

To change a line to an elliptical arc on the drawing page

  • Select the Pencil tool, point to the line segment's control point, and then drag to form an arc.

To change either an elliptical or circular arc to a straight line on the drawing page

  • Select the Pencil tool, point to the arc's control point, and then drag until it "snaps" into a straight line.

Note Changing the row type can alter a shape's width-height box and overwrite proportional or height-based formulas. For this reason, you might want to set LockCalcWH to true in the Protection section before changing a row type.

TOP

Useful Arc Formulas

You can control the resizing behavior of circular arcs using formulas that calculate the arc's bow and radius.

Calculate the bow from the radius and angle

If you know the radius of an arc and the angle that an ArcTo will subtend, you can calculate the bow with the following general equation:

If the bow is zero, the arc is a straight line. You can use this equation for any shape, open or closed, to create rounded corners that span a set angle, as shown in the following figure. The advantage of using circular arcs is that the corners resize smoothly. For example, if you know that the radius is 2 inches and the angle is 45 degrees, in an ArcTo row of the Geometry section, you would enter the following formula:

  • Geometry
  • n
  • .A
  • n
  • = 2 in. * (1 - COS(45 deg. /2))

Using a circular arc segment for a rounded corner

Using a circular arc segment for a rounded corner

  1. 90° angle
  1. Radius

In a shape such as a rectangle where the value of angle won't change (it's always 90 degrees), you can reduce part of the formula to a constant. If angle is always 90 degrees, (1�COS(angle/2)) = 0.2929. So you can enter the formula as follows:

  • Geometry
  • n
  • .A
  • n
  • = radius * 0.2929

Using this constant might speed up processing, but it limits flexibility if you later decide that the angle won't always be 90 degrees. For details about creating rounded corners, see Using Rounded Corner Styles earlier in this section.

Calculate the radius from the bow

If you know the bow of an arc, you can calculate its radius. To do this, find the magnitude of the chord—the distance between the arc's begin point and end point. In the following formula, X1, Y1 represent the arc's begin point, and X2, Y2 represent the arc's end point. The length of the chord, then, is:

And the radius is: