Previous Document Next Document

Object Model Reference : Classes : D : Document : Properties : Document.CurvePrecision


Document.CurvePrecision

Property CurvePrecision As Long

Description

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ézier 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 Document.SaveSettings and Document.RestoreSettings methods 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.

VBA example

The following VBA 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ézier 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 2013 Corel Corporation. All rights reserved.