Пример #1
0
        /// <summary>
        /// Calculates the size.
        /// </summary>
        /// <returns>The size.</returns>
        /// <param name="size">Size.</param>
        /// <param name="width">Width.</param>
        /// <param name="height">Height.</param>
        public static SKSize CalcSize(SkiaSharp.SKSize size, double width, double height)
        {
            double w;
            double h;

            if (width <= 0 && height <= 0)
            {
                return(size);
            }
            else if (width <= 0)
            {
                h = height;
                w = height * (size.Width / size.Height);
            }
            else if (height <= 0)
            {
                w = width;
                h = width * (size.Height / size.Width);
            }
            else
            {
                w = width;
                h = height;
            }

            return(new SkiaSharp.SKSize((float)w, (float)h));
        }
Пример #2
0
        /// <summary>
        /// Calculates the scale.
        /// </summary>
        /// <returns>The scale.</returns>
        /// <param name="originalSize">Original size.</param>
        /// <param name="scaledSize">Scaled size.</param>
        /// <param name="screenScale">Screen scale.</param>
        public static Tuple <float, float> CalcScale(SkiaSharp.SKSize originalSize, SkiaSharp.SKSize scaledSize, float screenScale)
        {
            var sx = scaledSize.Width * screenScale / originalSize.Width;
            var sy = scaledSize.Height * screenScale / originalSize.Height;

            return(new Tuple <float, float>((float)sx, (float)sy));
        }
Пример #3
0
 public void Inflate(SKSize size)
 {
     Inflate(size.Width, size.Height);
 }
Пример #4
0
        private SKRect AspectResize(SKSize size, bool fit)
        {
            if (size.Width == 0 || size.Height == 0 || Width == 0 || Height == 0)
                return SKRect.Create(MidX, MidY, 0, 0);

            float aspectWidth = size.Width;
            float aspectHeight = size.Height;
            float imgAspect = aspectWidth / aspectHeight;
            float fullRectAspect = Width / Height;

            bool compare = fit ? (fullRectAspect > imgAspect) : (fullRectAspect < imgAspect);
            if (compare)
            {
                aspectHeight = Height;
                aspectWidth = aspectHeight * imgAspect;
            }
            else
            {
                aspectWidth = Width;
                aspectHeight = aspectWidth / imgAspect;
            }
            float aspectLeft = MidX - (aspectWidth / 2f);
            float aspectTop = MidY - (aspectHeight / 2f);

            return SKRect.Create(aspectLeft, aspectTop, aspectWidth, aspectHeight);
        }
Пример #5
0
 public SKRect AspectFill(SKSize size) => AspectResize(size, false);
Пример #6
0
 public SKRect AspectFit(SKSize size) => AspectResize(size, true);
Пример #7
0
 public static SKSize Subtract(SKSize sz1, SKSize sz2) => sz1 - sz2;
Пример #8
0
 public static SKSize Add(SKSize sz1, SKSize sz2) => sz1 + sz2;
Пример #9
0
 public void Inflate(SKSize size)
 {
     Inflate(size.Width, size.Height);
 }
Пример #10
0
 public static SKPoint Add(SKPoint pt, SKSize sz) => pt + sz;
Пример #11
0
 public void DrawOval(SKPoint c, SKSize r, SKPaint paint)
 {
     DrawOval(c.X, c.Y, r.Width, r.Height, paint);
 }
Пример #12
0
 public void DrawRoundRect(SKRect rect, SKSize r, SKPaint paint)
 {
     DrawRoundRect(rect, r.Width, r.Height, paint);
 }
Пример #13
0
 public SKSvg(float pixelsPerInch, SKSize canvasSize)
     : base(pixelsPerInch, canvasSize)
 {
 }
Пример #14
0
 public SKSvg(SKSize canvasSize)
     : base(canvasSize)
 {
 }
Пример #15
0
 public static SKRect Create(SKPoint location, SKSize size)
 {
     return SKRect.Create(location.X, location.Y, size.Width, size.Height);
 }
Пример #16
0
 public static SKPoint Subtract(SKPoint pt, SKSize sz) => pt - sz;
Пример #17
0
 public static SKRect Create(SKSize size)
 {
     return SKRect.Create(SKPoint.Empty, size);
 }
Пример #18
0
 public void Deflate(SKSize size)
 {
     Deflate(size.Width, size.Height);
 }