diff options
Diffstat (limited to 'info/drawing-with-metapost/src/rec-dragon.mp')
-rw-r--r-- | info/drawing-with-metapost/src/rec-dragon.mp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/info/drawing-with-metapost/src/rec-dragon.mp b/info/drawing-with-metapost/src/rec-dragon.mp index 60b8549cf1..a1ccaf2edc 100644 --- a/info/drawing-with-metapost/src/rec-dragon.mp +++ b/info/drawing-with-metapost/src/rec-dragon.mp @@ -5,35 +5,35 @@ \begin{mplibcode} numeric r, theta; r = sqrt 1/2; theta = 45; vardef dragon(expr level, a, b) = - if level > 0: - save p; pair p; - p = r[a, b] rotatedabout(a, theta); - dragon(level - 1, a, p) & reverse dragon(level - 1, b, p) - else: - a .. b - fi + if level > 0: + save p; pair p; + p = r[a, b] rotatedabout(a, theta); + dragon(level - 1, a, p) & reverse dragon(level - 1, b, p) + else: + a .. b + fi enddef; vardef rounded_corners expr p = - save r, n; numeric r, n; r = 1/3; n = length p; - subpath (0, 1-r) of p - for t=1 upto n-1: - .. subpath (t+r, t+1-r) of p - endfor .. subpath (n-r, n) of p + save r, n; numeric r, n; r = 1/3; n = length p; + subpath (0, 1-r) of p + for t=1 upto n-1: + .. subpath (t+r, t+1-r) of p + endfor .. subpath (n-r, n) of p enddef; beginfig(1); - path d; d = dragon(15, origin, 240 right); - draw d withpen pencircle scaled 1/4 withcolor (.2, .2, .7); - label.top("The dragon curve at level 15", point 1/3 of bbox currentpicture); + path d; d = dragon(15, origin, 240 right); + draw d withpen pencircle scaled 1/4 withcolor (.2, .2, .7); + label.top("The dragon curve at level 15", point 1/3 of bbox currentpicture); - draw rounded_corners dragon(10, origin, 240 right) - shifted 280 down - withcolor .54 red; + draw rounded_corners dragon(10, origin, 240 right) + shifted 280 down + withcolor .54 red; + + label.top("\dots\ and at level 10 with rounded corners", point 1/3 of bbox currentpicture); - label.top("\dots\ and at level 10 with rounded corners", point 1/3 of bbox currentpicture); - endfig; \end{mplibcode} \end{document} |