PatternPen with a four-value pattern and LineJoin.Miter draws an EllipsePolygon almost solid
Một pull request liên quan đã được merge.
- #432 của @JimBobSquarePants — đã merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- csharp
- Lĩnh vực
- computer-graphics
Hướng nghiên cứu
Start by tracing how PatternPen applies the four-value dash pattern while drawing an EllipsePolygon with LineJoin.Miter; compare that path with the reported working two-value pattern and closed square. Reproduce with the supplied C# example and check the ink ratio against the expected 56–60%. The issue does not name source files or tests, so locate the drawing and pattern tests; done means the gaps remain visible and existing join and pattern cases still behave correctly.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp.Drawing
- I have verified if the problem exist in both
DEBUGandRELEASEmode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp.Drawing version
3.1.3
Other ImageSharp packages and versions
SixLabors.ImageSharp 4.1.3 (SixLabors.Fonts 3.2.0, SixLabors.PolygonClipper 1.0.2 via dependencies)
Environment (Operating system, version and so on)
Windows 11 x64
.NET Framework version
.NET 10 (SDK 10.0.401)
Description
A PatternPen with the four-value pattern [4, 2, 1, 2] and LineJoin.Miter draws an EllipsePolygon as an almost continuous line: the ink is 97 % of a solid pen with the same options, where about 56–60 % is expected. Only one gap remains visible.
The same pattern is correct on a closed square polygon. A two-value pattern [3, 2] is correct on the same ellipse. With the default join (Bevel) the four-value pattern is also correct on the ellipse (60 %), and with LineJoin.Round it is 66 %. So the combination of a short dash/gap pattern on a densely flattened curve with miter (and to a lesser extent round) joins seems to fill the gaps.
In ImageSharp.Drawing 2.1.6 the same drawing (with JointStyle.Miter, EndCapStyle.Butt) was dashed as expected.
| Join, cap | [3, 2] |
[4, 2, 1, 2] |
|---|---|---|
| default (Bevel, Butt) | 60 % | 60 % |
| Miter, Butt | 60 % | 97 % |
| Round, Butt | 60 % | 66 % |
| Miter, Round | 74 % | 101 % |
(ink as a share of a solid pen with the same StrokeOptions; circle of 200 px diameter, pen width 2, 256 × 256 image)
Steps to Reproduce
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
IPath circle = new EllipsePolygon(128, 128, 200, 200);
double Ink(Pen pen)
{
using var image = new Image<Rgba32>(256, 256, Color.White.ToPixel<Rgba32>());
image.Mutate(ctx => ctx.Paint(canvas => canvas.Draw(pen, circle)));
double ink = 0;
image.ProcessPixelRows(rows =>
{
for (var y = 0; y < rows.Height; y++)
foreach (var p in rows.GetRowSpan(y))
ink += (255 - p.R) / 255.0;
});
return ink;
}
var stroke = new StrokeOptions { LineJoin = LineJoin.Miter, LineCap = LineCap.Butt };
var solid = Ink(new SolidPen(new PenOptions(Color.Black, 2, []) { StrokeOptions = stroke }));
var dashed = Ink(new PatternPen(new PenOptions(Color.Black, 2, [4f, 2f, 1f, 2f]) { StrokeOptions = stroke }));
Console.WriteLine($"{dashed / solid:P0}"); // 97 %, expected about 56–60 %
Images
The arc is drawn as a continuous line with a single gap, instead of dash, gap, dot, gap.
- Ngôn ngữ chính
- C#
- Star
- 322
- Fork
- 49
- Merge trung bình
- 3 giờ 27 phút
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SixLabors/ImageSharp.Drawing
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
SixLabors/ImageSharp.Drawing#438 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
SixLabors/ImageSharp.Drawing#319 · 2 bình luận ·
Tất cả issue của SixLabors/ImageSharp.Drawing
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
NetSparkleUpdater/NetSparkle#762 ·
-
ANSIInitializer.Enabled getterĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
bug effort:S P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
nightscout/nocturne#4563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Tyrrrz/YoutubeDownloader#925 ·
-
Bad contrast in light modeĐang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày