aboutsummaryrefslogtreecommitdiff
path: root/Emby.Drawing/PercentPlayedDrawer.cs
blob: 52b4329e1ea057859d13706fcf1f0fdf4e4e68f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using MediaBrowser.Model.Drawing;
using SkiaSharp;

namespace Emby.Drawing
{
    public static class PercentPlayedDrawer
    {
        private const int IndicatorHeight = 8;

        public static void Process(SKCanvas canvas, ImageSize imageSize, double percent)
        {
            using (var paint = new SKPaint())
            {
                var endX = imageSize.Width - 1;
                var endY = imageSize.Height - 1;

                paint.Color = SKColor.Parse("#99000000");
                paint.Style = SKPaintStyle.Fill;
                canvas.DrawRect(SKRect.Create(0, (float)endY - IndicatorHeight, (float)endX, (float)endY), paint);

                double foregroundWidth = endX;
                foregroundWidth *= percent;
                foregroundWidth /= 100;

                paint.Color = SKColor.Parse("#FF52B54B");
                canvas.DrawRect(SKRect.Create(0, (float)endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), (float)endY), paint);
            }
        }
    }
}