Skip to content

Scalebar: fix rendering artifact #4329

@swharden

Description

@swharden

I just merged #4328 to address #4319 but there's a rendering artifact due to the L shaped scalebar being drawn as two lines. Using a "path" with 3 points would fix this issue.

The issue can be seen in the cookbook recipe:

var scalebar = myPlot.Add.ScaleBar(5, 0.25);
scalebar.LineWidth = 5;
scalebar.LineColor = Colors.Magenta;

image

The fix may be implemented here by using DrawPath instead of DrawLine:

// TODO: use a path instead of two distinct lines to prevent artifacts at the corner
if (Width > 0)
{
Drawing.DrawLine(rp.Canvas, paint, hLine, LineStyle);
Pixel xCenter = new((hLine.X1 + hLine.X2) / 2, hLine.Y1 + LabelPadding.Top);
XLabelStyle.Render(rp.Canvas, xCenter, paint, XLabel);
}
if (Height > 0)
{
Drawing.DrawLine(rp.Canvas, paint, vLine, LineStyle);
Pixel yCenter = new(vLine.X1 + LabelPadding.Right, (vLine.Y1 + vLine.Y2) / 2);
YLabelStyle.Render(rp.Canvas, yCenter, paint, YLabel);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueThis issue has limited complexity and may be a good start for new contributorsHelp WantedScott won't do this soon, but PRs from the community are welcome!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions