Skip to content

Commit

Permalink
hobby: Fix closed two point hobby curve (#468)
Browse files Browse the repository at this point in the history
Fixes #462.
  • Loading branch information
johannes-wolf authored Jan 18, 2024
1 parent 303d1bf commit eaed74f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/hobby.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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),)
}
Expand Down
Binary file modified tests/hobby/ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 21 additions & 13 deletions tests/hobby/test.typ
Original file line number Diff line number Diff line change
@@ -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)
})

0 comments on commit eaed74f

Please sign in to comment.