Previous Document Next Document

Object Model Reference : Classes : S : Segment : Methods : Segment.GetPeaks


Segment.GetPeaks

Function GetPeaks(Angle As Double, Offset1 As Double, Offset2 As Double, [OffsetType As cdrSegmentOffsetType = cdrParamSegmentOffset]) As Long

Description

Member of Segment

The GetPeaks method returns the number of points where a tangent at a specified angle can touch a curve segment. A segment can have up to two peaks.

Parameter
Description
Angle
Specifies the angle, measured in degrees
Offset1
Specifies the offset, in document units, of the first tangent from the beginning of the curve
Offset2
Specifies the offset, in document units, of the second tangent from the beginning of the curve
OffsetType
Specifies the type of offset of the point on the curve’s subpath, and returns cdrSegmentOffsetType. This parameter is optional, and its default value is cdrParamSegmentOffset (2).

VBA example

The following VBA example marks the points on a curve through which tangents can be drawn at 30°.

Sub Test()
Const Angle As Double = 30
Dim seg As Segment
Dim t1 As Double, t2 As Double, n As Long
For Each seg In ActiveShape.Curve.Segments
n = seg.GetPeaks(Angle, t1, t2)
If n > 1 Then MarkPoint seg, t2, Angle
If n > 0 Then MarkPoint seg, t1, Angle
Next seg
End Sub
Private Sub MarkPoint(seg As Segment, t As Double, Angle As Double)
Dim x As Double, y As Double
Dim dx As Double, dy As Double
Dim s As Shape, a As Double
a = Angle * 3.1415926 / 180
dx = 1.5 * Cos(a)
dy = 1.5 * Sin(a)
seg.GetPointPositionAt x, y, t, cdrParamSegmentOffset
ActiveLayer.CreateLineSegment x + dx, y + dy, x - dx, y - dy
Set s = ActiveLayer.CreateEllipse2(x, y, 0.05)
s.Fill.UniformColor.RGBAssign 255, 0, 0
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.