Deformed stroke for some length values fix (#3860)

This commit is contained in:
Tomás Cruz 2024-04-06 12:21:38 +01:00 committed by GitHub
parent 3d4de954aa
commit 5de36f7b97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View File

@ -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)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

View File

@ -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),
)