From 40d1dab7681a119fabc376e81a43f79b5e2de7ef Mon Sep 17 00:00:00 2001 From: Johannes Wolf Date: Sat, 7 Dec 2024 13:42:15 +0100 Subject: [PATCH 1/2] canvas: Panic if length is infinite --- src/canvas.typ | 2 ++ src/path-util.typ | 2 +- tests/decorations/path/test.typ | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/canvas.typ b/src/canvas.typ index bb4ca973..9fd07cc2 100644 --- a/src/canvas.typ +++ b/src/canvas.typ @@ -32,6 +32,8 @@ } assert(length / 1cm != 0, message: "Canvas length must be != 0!") + assert(not float.is-infinite(length / 1cm), + message: "Length must not be infinite!") let ctx = ( version: version.version, diff --git a/src/path-util.typ b/src/path-util.typ index 02af4b81..5a07c00f 100644 --- a/src/path-util.typ +++ b/src/path-util.typ @@ -260,7 +260,7 @@ } } - let segment = segment-at-t(segments, t, samples: samples, rev: rev) + let segment = segment-at-t(segments, t, samples: samples, rev: rev, clamp: true) return if segment != none { let (distance, segment, length, ..) = segment _point-on-segment(segment, if rev { length - distance } else { distance }, samples: samples, extrapolate: extrapolate) diff --git a/tests/decorations/path/test.typ b/tests/decorations/path/test.typ index 9090fdc1..690661bb 100644 --- a/tests/decorations/path/test.typ +++ b/tests/decorations/path/test.typ @@ -90,3 +90,11 @@ wave(line((0,0), (4,0)), segments: 1) }) + +// Bug #757: Coil only works with specific order +#test-case({ + import draw: * + let a = (1, 0) + let b = (0.12, 0.4) + coil(hobby(b, a), amplitude:0.21, segment-length:0.05112, align:"MID") +}) From 157ed704df3d01379117a1b83c58edc86ee12c18 Mon Sep 17 00:00:00 2001 From: Johannes Wolf Date: Sat, 7 Dec 2024 13:44:58 +0100 Subject: [PATCH 2/2] tests: Add test case for bug #757 --- tests/decorations/path/test.typ | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/decorations/path/test.typ b/tests/decorations/path/test.typ index 690661bb..431cf38e 100644 --- a/tests/decorations/path/test.typ +++ b/tests/decorations/path/test.typ @@ -92,9 +92,9 @@ }) // Bug #757: Coil only works with specific order -#test-case({ +#block(width: 10cm, canvas(length:10cm,{ import draw: * let a = (1, 0) - let b = (0.12, 0.4) - coil(hobby(b, a), amplitude:0.21, segment-length:0.05112, align:"MID") -}) + let b = (0.12, 0.3) + coil(hobby(b,a),amplitude:0.051,segment-length:0.05112,align:"MID") +}))