summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomás Cruz <103905440+Tom4sCruz@users.noreply.github.com>2024-04-06 12:21:38 +0100
committerGitHub <noreply@github.com>2024-04-06 11:21:38 +0000
commit5de36f7b97c237ad0fc4a0b4ccecd7adcb43181b (patch)
treee4466d2ec0949ea9e2d44580942b2f0deb48003f
parent3d4de954aaeb072a1df2bedf7f93785b3498bc69 (diff)
Deformed stroke for some length values fix (#3860)
-rw-r--r--crates/typst/src/visualize/shape.rs2
-rw-r--r--tests/ref/bugs/3700-deformed-stroke.pngbin0 -> 144 bytes
-rw-r--r--tests/typ/bugs/3700-deformed-stroke.typ11
3 files changed, 12 insertions, 1 deletions
diff --git a/crates/typst/src/visualize/shape.rs b/crates/typst/src/visualize/shape.rs
index 4567739e..e37e5f90 100644
--- a/crates/typst/src/visualize/shape.rs
+++ b/crates/typst/src/visualize/shape.rs
@@ -1108,7 +1108,7 @@ impl ControlPoints {
+ 2.0 * (o.y - c_i.y).to_raw() * (c_i.y - c_o.y).to_raw();
let c = (c_i.x - c_o.x).to_raw().powi(2) + (c_i.y - c_o.y).to_raw().powi(2)
- r.to_raw().powi(2);
- let t = (-b + (b * b - 4.0 * a * c).sqrt()) / (2.0 * a);
+ let t = (-b + (b * b - 4.0 * a * c).max(0.0).sqrt()) / (2.0 * a);
c_i + t * (o - c_i)
}
diff --git a/tests/ref/bugs/3700-deformed-stroke.png b/tests/ref/bugs/3700-deformed-stroke.png
new file mode 100644
index 00000000..f1db2836
--- /dev/null
+++ b/tests/ref/bugs/3700-deformed-stroke.png
Binary files differ
diff --git a/tests/typ/bugs/3700-deformed-stroke.typ b/tests/typ/bugs/3700-deformed-stroke.typ
new file mode 100644
index 00000000..7ca6ba6b
--- /dev/null
+++ b/tests/typ/bugs/3700-deformed-stroke.typ
@@ -0,0 +1,11 @@
+// Test shape fill & stroke for specific values that used to make the stroke
+// deformed.
+// https://github.com/typst/typst/issues/3700
+
+---
+#rect(
+ radius: 1mm,
+ width: 100%,
+ height: 10pt,
+ stroke: (left: rgb("46b3c2") + 16.0mm),
+) \ No newline at end of file