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] The position draw on SKXamCanvas is not correct. #1585

Closed
xtuzy opened this issue Jan 22, 2021 · 1 comment
Closed

[BUG] The position draw on SKXamCanvas is not correct. #1585

xtuzy opened this issue Jan 22, 2021 · 1 comment

Comments

@xtuzy
Copy link

xtuzy commented Jan 22, 2021

Description
I try use skiasharp draw something on uwp, but i find the position draw on SKXamCanvas is not correct.
when i draw a point on (50,50), i use mouse click the point ,get (40,40) by e.GetCurrentPoint(view).Position,
when i draw a point on (100,100),i use mouse click the point ,get (80,80) by e.GetCurrentPoint(view).Position,
when i draw a point on (400,400), i use mouse click the point ,get (320,320) by e.GetCurrentPoint(view).Position.
Then i use win2d.uwp do same thing, it's correct, draw point on (50,50),click it, i can get (50,50).
Then i use SKCanvasView do it on Android, it's correct,.

Code

if(something){
//something
}
//use win2d
else if (e.ClickedItem.Equals(Win2DDrawPositionTestListItem))
{
  //Container is a Grid
  Container.Children.Clear();
  var view = new CanvasControl();
  Container.Children.Add(view);
  
  Point clickPoint = new Point(0, 0);
  view.Draw += (senderTemp, eTemp) =>
  {
      var graphics = eTemp.DrawingSession;
      graphics.FillCircle(new System.Numerics.Vector2(50, 50), 2, SKColors.Red.ToColor());
      graphics.FillCircle(new System.Numerics.Vector2(100, 100), 2, SKColors.Red.ToColor());
      graphics.FillCircle(new System.Numerics.Vector2(400, 400), 2, SKColors.Red.ToColor());
      if (clickPoint.X != 0)
      {
          graphics.FillCircle(new System.Numerics.Vector2(400, 400), 1, SKColors.Yellow.ToColor());
      }
  };
  view.PointerPressed += (senderTemp, eTemp) =>
  {
       clickPoint = eTemp.GetCurrentPoint(view).Position;
       Debug.WriteLine(DateTime.Now + ": Click Position (" + clickPoint.X + "," + clickPoint.Y + ")");
   };
}
//use Skiasharp
else if (e.ClickedItem.Equals(SkiaDrawPositionTestListItem))
{
  Container.Children.Clear();
  var view = new SKXamlCanvas();
  Container.Children.Add(view);

  Point clickPoint = new Point(0, 0);
  var paint = new SKPaint() { Color = SKColors.Red, Style = SKPaintStyle.Fill };
  view.PaintSurface += (senderTemp, eTemp) =>
  {
      var graphics = eTemp.Surface.Canvas;
      graphics.DrawCircle(new SKPoint(50, 50), 5, paint);
      graphics.DrawCircle(new SKPoint(100, 100), 5, paint);
      graphics.DrawCircle(new SKPoint(400, 400), 5, paint);
      if (clickPoint.X != 0)
      {
          paint.Color = SKColors.Yellow;
          graphics.DrawCircle(clickPoint.ToSKPoint(), 3, paint);
      }
  };
  view.PointerPressed += (senderTemp, eTemp) =>
  {
      clickPoint = eTemp.GetCurrentPoint(view).Position;
      Debug.WriteLine(DateTime.Now + ": Click Position (" + clickPoint.X + "," + clickPoint.Y + ")");
  };
}

Xaml, this canvas will be replaced by win2d or skiasharp in C# code

<Grid x:Name="Container" Margin="12,12,0,0 " Grid.Row="2" >
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <skia:SKXamlCanvas Name="canvas"  Background="Azure"/>
</Grid>

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue: 2.80.2
  • Last known good version:
  • IDE: Visual Studio
  • Platform Target Frameworks:
    • Android:
    • iOS:
    • Linux:
    • macOS:
    • Tizen:
    • tvOS:
    • UWP: 18362
    • watchOS:
    • Windows Classic:
  • Target Devices:
Detailed IDE/OS information (click to expand)

PASTE ANY DETAILED VERSION INFO HERE

Screenshots

Reproduction Link

@xtuzy xtuzy closed this as completed Jan 24, 2021
@mattleibow
Copy link
Contributor

Was this a bug that you worked around?

@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants