mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.48k stars 538 forks source link

[BUG] Y axis is inverted #1520

Closed EmilAlipiev closed 4 years ago

EmilAlipiev commented 4 years ago

Description

I saw this existing issue https://github.com/mono/SkiaSharp/issues/231 but not sure if it is related. Basically when I draw a simple Path, the more increase the Y axis, path is moving down not to the upper direction as i would expect. Here is the code sample.


   var  indicatorStrokePaint = new SKPaint
            {
                Style = SKPaintStyle.Stroke,
                StrokeWidth = 6,
                Color = strokeColor,
                IsAntialias = true
            };

               var start = new SKPoint(500, 70);
                var end = new SKPoint(500, 100);

                canvas.DrawLine(start, end, indicatorStrokePaint);

Screenshot for above code red line is the path I am drawing

image

if i increase those numbers like

   var start = new SKPoint(500, 100);
                var end = new SKPoint(500, 130);

you can see below that red path was drawn more below than the gauge. image

Expected Behavior

I would expect that the more i increase the y axis, it should draw more upper.

Actual Behavior

goes down

Basic Information

mattleibow commented 4 years ago

SkiaSharp uses the top-left origin. Positive X is to the right, positive Y is down.

This is counter to macOS coordinates and GPU. However, it is pretty common with 2D screen-based rendering engines.

EmilAlipiev commented 4 years ago

oh ok good to know. I thought that there is a bug :) thanks for making it clear for me.