jellyfin/Emby.Drawing/PercentPlayedDrawer.cs

32 lines
1.0 KiB
C#
Raw Normal View History

using System;
2017-05-09 12:53:46 -07:00
using MediaBrowser.Model.Drawing;
using SkiaSharp;
2017-05-09 12:53:46 -07:00
namespace Emby.Drawing
2017-05-09 12:53:46 -07:00
{
2019-01-20 06:25:13 -07:00
public static class PercentPlayedDrawer
2017-05-09 12:53:46 -07:00
{
private const int IndicatorHeight = 8;
2019-01-20 06:25:13 -07:00
public static void Process(SKCanvas canvas, ImageSize imageSize, double percent)
2017-05-09 12:53:46 -07:00
{
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);
}
}
}
}