Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shapes: Bezier Previous Position #305

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/draw/shapes.typ
Original file line number Diff line number Diff line change
Expand Up @@ -711,15 +711,15 @@
len in (1, 2),
message: "Bezier curve expects 1 or 2 control points. Got " + str(len),
)
let coordinates = (start, end, ..ctrl)
let coordinates = (start, ..ctrl, end)

// Coordinates check
let t = coordinates.map(coordinate.resolve-system)

return (
ctx => {
let (ctx, start, end, ..ctrl) = coordinate.resolve(ctx, ..coordinates)
let (ctx, start, ..ctrl, end) = coordinate.resolve(ctx, ..coordinates)

if ctrl.len() == 1 {
(start, end, ..ctrl) = bezier_.quadratic-to-cubic(start, end, ..ctrl)
}
Expand Down
Binary file added tests/bezier/ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions tests/bezier/test.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#set page(width: auto, height: auto)
#import "/src/lib.typ": *

/* Make sure the current position is set to the curves end point [236] */
#block(stroke: 2pt + red, canvas(length: .5cm, {
import draw: *

set-style(radius: .1)
circle((), fill: green)
bezier((0,0), (3, 0), (1,1), (2,-1))
circle((), fill: red)
}))
Loading