Previous Document Next Document
Document.CurvePrecision

Property CurvePrecision As Long

Member of Document

The CurvePrecision property determines the linearization factor for curves.

It is not possible to find the mathematically precise length of a B閦ier curve, or to find a point along a curve at given distance from its beginning. In these cases, the curve is divided in a number of line segments (internally) while performing calculations. The CurvePrecision property determines how many line segments constitute a single curve segment. Usually, the value of 50 gives a rather good approximation for most applications. Increasing this value improves precision but also increases the computation time needed to perform an operation.

When you change these parameters, it is recommended that you preserve previous values and then restore them at the end of the script. You can use the SaveSettings and RestoreSettings methods of the Document object to do this, or you can just store the property value in a local variable during macro execution.

This method affects only VBA methods and has no effect on internal tools and algorithms of CorelDRAW.

The following code example creates a circle with diameter of 1", converts it to curves, and then shows the curve length with different curve precision settings.

Although the curve length in this example should be equal to pi (3.1415926...), it is never very close to that because it is not possible to represent a perfect circle using cubic B閦ier curves. (That is, although an ellipse looks like an ellipse, it is just a rough approximation.)

Sub Test() 
 Dim s As Shape 
 Set s = ActiveLayer.CreateEllipse2(4, 5, 0.5) 
 s.ConvertToCurves 
 With ActiveDocument 
  .SaveSettings 
  .CurvePrecision = 10 
  MsgBox s.Curve.Length 
  .CurvePrecision = 50 
  MsgBox s.Curve.Length 
  .RestoreSettings 
 End With 
End Sub 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.