diff options
author | David Thompson <dthompson2@worcester.edu> | 2021-10-02 07:59:02 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2021-10-02 07:59:02 -0400 |
commit | 4429ae6b9a00914a912599160d671f7540368975 (patch) | |
tree | 49eb75fbeb01e0a0c191f5248725fc563aad2b0a | |
parent | 0559473fbfc28f5b05a9a23402dad28865c46231 (diff) |
graphics: path: Add bezier-path procedure.
-rw-r--r-- | chickadee/graphics/path.scm | 12 | ||||
-rw-r--r-- | doc/api.texi | 8 |
2 files changed, 20 insertions, 0 deletions
diff --git a/chickadee/graphics/path.scm b/chickadee/graphics/path.scm index 27eb0b1..c4e2b89 100644 --- a/chickadee/graphics/path.scm +++ b/chickadee/graphics/path.scm @@ -56,6 +56,7 @@ arc-to line polyline + bezier-path rectangle square rounded-rectangle @@ -361,6 +362,17 @@ (line-to p2) (map line-to prest))) +(define (bezier-path p1 c1 c2 p2 . points) + (apply path + (move-to p1) + (bezier-to c1 c2 p2) + (let loop ((points points)) + (match points + (() '()) + ((c1 c2 p . rest) + (cons (bezier-to c1 c2 p) + (loop rest))))))) + (define (rectangle bottom-left width height) (let ((x (vec2-x bottom-left)) (y (vec2-y bottom-left))) diff --git a/doc/api.texi b/doc/api.texi index 87ff7cd..9a36bc4 100644 --- a/doc/api.texi +++ b/doc/api.texi @@ -2106,6 +2106,14 @@ Return a path that draws a straight line from @var{start} to @var{end}. Return a path that draws a series of lines connecting @var{points}. @end deffn +@deffn {Procedure} bezier-path p1 c1 c2 p2 . points +Return a path that draws a series of bezier points starting at +@var{p1}, moving to @var{p2} using control points @var{c1} and +@var{c2}, and proceeding to draw additional bezier curves as defined +by @var{points}. Each additional curve requires 3 additional +arguments: two control points and and an ending point. +@end deffn + @deffn {Procedure} rectangle bottom-left width height Return a path that draws a rectangle whose bottom-left corner is at @var{bottom-left} and whose size is defined by @var{width} and |