Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Horizontal lines disappear when zoomed in #2856

Open
1 task done
afcsoft opened this issue May 12, 2024 · 7 comments
Open
1 task done

[BUG] Horizontal lines disappear when zoomed in #2856

afcsoft opened this issue May 12, 2024 · 7 comments

Comments

@afcsoft
Copy link

afcsoft commented May 12, 2024

Description

resim
resim
Horizontal lines disappear when zoomed in using Matrix.
Stroke width is irrelevant. Anti-aliasing helps to some extent but problem still pursue.

Code

// Matrix code
        var zoom = (float)skiaRenderer.Viewport.SceneZ;
        var dpi = 1.5f;

        var drawMatrix = SKMatrix.CreateScale((float)zoom, -(float)zoom);

        var halfScaledWidth = (float)canvas.ActualWidth * 0.5f;
        var halfScaledHeight = (float)canvas.ActualHeight * 0.5f;

        var actualX = -(float)skiaRenderer.Viewport.SceneX * zoom + (halfScaledWidth * dpi);
        var actualY = (float)skiaRenderer.Viewport.SceneY * zoom + (halfScaledHeight * dpi);

        drawMatrix.TransX = actualX;
        drawMatrix.TransY = actualY;

        e.Surface.Canvas.SetMatrix(drawMatrix);      
// Line drawing code
_paint.Color.WithAlpha(255);
_paint.IsAntialias = true;
_paint.StrokeWidth = (float)(1.5 / _viewport.SceneZ);
_paint.StrokeCap = SKStrokeCap.Round;
_paint.IsStroke = true;
surface.Canvas.DrawLine((float)line.Object.Coor.Y, (float)line.Object.Coor.X, (float)line.Coord.Y, (float)line.Coord.X, _paint);

Expected Behavior

No response

Actual Behavior

No response

Version of SkiaSharp

2.88.3 (Current)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

All

Platform / Operating System Version

No response

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@angelofb
Copy link

I have the same problem

if you can use 1 pixel width stroke then you can set hairline mode with StrokeWidth = 0
https://learn.microsoft.com/en-us/dotnet/api/skiasharp.skpaint.strokewidth?view=skiasharp-2.88#remarks

@taublast
Copy link
Contributor

Try Math.Round() actualX and actualY and let us know.

@mattleibow
Copy link
Contributor

I think this will need a sample. It can just be a simple drawing of a line and "zooming" with a slider or something.

There may be things you can do with the hairline if the line gets too thin (like @angelofb says) or make sure your values are not in some weird decimal value (like @taublast says).

But, if you can capture the values when they disappear, then we can also see.

Also, try the 3.x releases and see if the new Skia engine has any bug fixes. However, this is more likely you have a 0.1px line at a 0.3px offset with a scale of 1.05% or something.

Copy link
Contributor

Hi @afcsoft. We have added the status/needs-repro label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Copy link
Contributor

Hi @afcsoft. We have added the status/needs-info label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants