diff --git a/src/hobby.typ b/src/hobby.typ index 65bc08fb..1c1970e0 100644 --- a/src/hobby.typ +++ b/src/hobby.typ @@ -271,7 +271,7 @@ assert(omega.all(x => x >= 0), message: "Omega must contain positive values only") - if points.len() == 2 { + if not close and points.len() == 2 { let (a, b) = points return ((a, b, a, b),) } diff --git a/tests/hobby/ref.png b/tests/hobby/ref.png index f014478a..d43cf342 100644 Binary files a/tests/hobby/ref.png and b/tests/hobby/ref.png differ diff --git a/tests/hobby/test.typ b/tests/hobby/test.typ index 04d851f1..7ae79dba 100644 --- a/tests/hobby/test.typ +++ b/tests/hobby/test.typ @@ -1,27 +1,35 @@ #set page(width: auto, height: auto) #import "/src/lib.typ": * +#import "/tests/helper.typ": * -#box(stroke: 2pt + red, canvas({ - import draw: * - hobby((0,0), (1,0)) -})) - -#box(stroke: 2pt + red, canvas({ +#test-case({ import draw: * hobby((0,-1), (1,1), (2,0), (3,1), (4,0), (5,2), omega: 0) -})) +}) -#box(stroke: 2pt + red, canvas({ +#test-case({ import draw: * hobby((0,-1), (1,1), (2,0), (3,1), (4,0), (5,2), omega: .5) -})) +}) -#box(stroke: 2pt + red, canvas({ +#test-case({ import draw: * hobby((0,-1), (1,1), (2,0), (3,1), (4,0), (5,2), omega: 1) -})) +}) -#box(stroke: 2pt + red, canvas({ +#test-case({ import draw: * hobby((0,-1), (1,1), (2,0), (3,1), (4,0), (5,2), close: true, fill: blue) -})) +}) + +// Two points, not closed +#test-case({ + import draw: * + hobby((0,0), (1,1)) +}) + +// Two points, closed +#test-case({ + import draw: * + hobby((0,0), (1,1), close: true) +})