Middlepoint on a curve created by AddPathCurve

Just starting out? Need help? Post your questions and find answers here.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Middlepoint on a curve created by AddPathCurve

Post by Fred »

Nice use of the vector lib :)
l1marik
User
User
Posts: 52
Joined: Tue Jun 30, 2020 6:22 am

Re: Middlepoint on a curve created by AddPathCurve

Post by l1marik »

Little John wrote:Oops, I'm too slow. :-) While I was writing an answer, you posted again ...
Well, here is my reply, I hope that it's understandable.

Code: Select all

Procedure AddPathBezierCurve(List Points.struct_Point(), xDisplacement.d = 0, yDisplacement.d = 0)
   Protected halfLen.d=0.0, temp.d=0.0
   
   ForEach Points()
      If (Not ListIndex(Points()))
         MovePathCursor(xDisplacement + Points()\x, yDisplacement + Points()\y)
      Else
         Select (ListSize(Points()) - ListIndex(Points()))
            Case 1
               [...]
               AddPathCurve(x1, y1, x2, y2, x3, y3)
               halfLen + <length of this Bezier segment As shown before>
            Case 2
               [...]
               AddPathCurve(x1, y1, x2, y2, x3, y3)
               halfLen + <length of this Bezier segment As shown before>
            Default
               [...]
               AddPathCurve(x1, y1, x2, y2, x3, y3)
               halfLen + <length of this Bezier segment As shown before>
         EndSelect
      EndIf
   Next
   halfLen / 2
   
   ForEach Points()
      If (Not ListIndex(Points()))
         ; MovePathCursor(xDisplacement + Points()\x, yDisplacement + Points()\y)
      Else
         Select (ListSize(Points()) - ListIndex(Points()))
            Case 1
               [...]
               temp + <length of this Bezier segment As shown before>
               If temp > halfLen
                  Break
               EndIf   
            Case 2
               [...]
               temp + <length of this Bezier segment As shown before>
               If temp > halfLen
                  Break
               EndIf   
            Default
               [...]
               temp + <length of this Bezier segment As shown before>
               If temp > halfLen
                  Break
               EndIf   
         EndSelect
      EndIf
   Next
   excess = temp - halfLen
   ; The Break took place in the Bezier segment where the midpoint of the whole curve is.
   ; Now investigate that segment similar as shown before. However, now don't look for
   ; the midpoint of that segment, but for <length of that segment> - excess. 
EndProcedure
Your image looks impressive. Image
Absolutely perfect would be to have the text following the curve [...]
You might want to look at Danilo's DrawBezierText().
Dear Little John, do you have working example?

THX
Little John
Addict
Addict
Posts: 4778
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Middlepoint on a curve created by AddPathCurve

Post by Little John »

l1marik wrote:Dear Little John, do you have working example?
No, sorry. I only have that sketch of my approach, which was just meant as a suggestion for Didelphodon.
Post Reply