home *** CD-ROM | disk | FTP | other *** search
- /* given four control points (that's eight arguments) this draws a bspline */
-
- parse arg x1 y1 x2 y2 x3 y3 x4 y4
-
- length = max(abs(x1-x4), abs(y1-74))
-
- if (length = 0) then exit
-
- d1 = abs((x1 - x4) * (y2 - y4) - (y1 - y4) * (x2 - x4)) / length
- d2 = abs((x1 - x4) * (y3 - y4) - (y1 - y4) * (x3 - x4)) / length
-
- /* if they are colinear, simply draw a line. */
-
- if (d1 < 0.5) & (d2 < 0.5) then do
-
- address 'freedraw' 'Line ' trunc(x1) trunc(y1) trunc(x4) trunc(y4)
-
- /* otherwise invoke recursively on substrings */
-
- end
- else do
-
- x12 = (x1 + x2) / 2
- y12 = (y1 + y2) / 2
- x23 = (x2 + x3) / 2
- y23 = (y2 + y3) / 2
- x34 = (x3 + x4) / 2
- y34 = (y3 + y4) / 2
- x123 = (x12 + x23) / 2
- y123 = (y12 + y23) / 2
- x234 = (x23 + x34) / 2
- y234 = (y23 + y34) / 2
- x1234 = (x123 + x234) / 2
- y1234 = (y123 + y234) / 2
-
- address 'freedraw' 'Spawn aspline ' x1 y1 x12 y12 x123 y123 x1234 y1234
- address 'freedraw' 'Spawn aspline ' x1234 y1234 x234 y234 x34 y34 x4 y4
-
- end
-