Coreldraw VBA drawing Curves

Guys

trying to learn to draw in VBA. I have got the drawing of lines understood but am having problems on how to do curves

I use the following code

    Dim s As Shape
    Dim crv As Curve
    Dim sp As SubPath
    Dim c As New Color
    ActiveDocument.Unit = cdrMillimeter
    Set crv = CreateCurve(ActiveDocument)
    Set sp = crv.CreateSubPath(0, 0)
    sp.AppendLineSegment 0, 0, False ' NODE1
    sp.AppendLineSegment 0, 100, False ' NODE2
    sp.AppendLineSegment 200, 100, False ' NODE3
    sp.AppendLineSegment 200, 75, False ' NODE4
    sp.AppendLineSegment 0, 0, False ' NODE5
    sp.Closed = True
    Set s = ActiveLayer.CreateCurve(crv)

This draws the shape below which I have annotated with the node numbers to match the code

I Want to curve the line between nodes 4 and 5 so that there is an even curve upwards as shown below

I am sure it it done by using SubPath.AppendCurveSegment method but i'm not sure how to implement it

is there any chance of an explanation of what figures are needed in order to achieve the above

My Understanding is the first two options are the x & y coordinates of the line you are curving but i'm not sure whether I use node 4 or 5

its after that I Don't know what they are. I Think options 4&6 are the angle of the curve but have no idea what to use

I wish Corel would come out with a complete reference guide with examples and explanations of each parameter as I find the API guide on the site very hit and miss which either give examples and no explanation or an explanation but no example

Any help is appreciated

Mark

Parents
No Data
Reply
  • SubPath.AppendCurveSegment is adding a Curve Segment to a Subpath. The shape of that segment depends on the lengths and angles of the starting and ending control points of that segment.

    Look at the code we used recently for making a rectangular Curve with one side "puckered". In that case, we identified a Segment, changed it to be a Curve Segment, and then set lengths and angles for the starting and ending control points to shape it the way we wanted. With AppendCurveSegment, those can be set at the time that the segment is created.

    Note that there is also a SubPath.AppendCurveSegment2 method that doesn't use the lengths and angles of the starting and ending control points of the segment, but instead specifies the x and y coordinates of those control points.

Children