linebender / linebender/tiny-skia
Hairline stroking at half-pixel offset + `LineCap::Square` produces artifacts
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 99
- Avg merge
- 2h 52m
- Merged PRs (30d)
- 1
Description
```rust
use tiny_skia::*;
fn main() {
let mut paint = Paint::default();
paint.set_color_rgba8(255, 0, 0, 255);
paint.anti_alias = true;
let path = {
let mut pb = PathBuilder::new();
pb.move_to(2.5, 1.5);
pb.line_to(5.5, 1.5);
pb.line_to(5.5, 5.5);
pb.line_to(2.5, 5.5);
pb.close();
pb.finish().unwrap()
};
let mut stroke = Stroke::default();
stroke.width = 1.0;
stroke.line_cap = LineCap::Square;
let mut pixmap = Pixmap::new(7, 7).unwrap();
pixmap.stroke_path(&path, &paint, &stroke, Transform::identity(), None);
pixmap.save_png("image.png").unwrap();
}
```
produces (8x upscale, actual/expected):


This issue can be "fixed" by not using `LineCap::Square`, by using larger stroke width (which would simply disable hairline stroking) and by closing the path manually, without relying on ClosePath/Z.
The Skia itself produces similar results, but not quite the same. Not sure if this is actually a Skia bug or an intentional behaviour.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Rust reproduction and compare its generated image with the attached actual and expected results. Trace hairline stroking with a half-pixel offset, LineCap::Square, and ClosePath/Z, then compare the behavior with Skia. Done means determining whether the artifact is intentional or correcting it with a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100