PercentPlayedDrawer.cs 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using MediaBrowser.Model.Drawing;
  3. using SkiaSharp;
  4. namespace Emby.Drawing
  5. {
  6. public static class PercentPlayedDrawer
  7. {
  8. private const int IndicatorHeight = 8;
  9. public static void Process(SKCanvas canvas, ImageSize imageSize, double percent)
  10. {
  11. using (var paint = new SKPaint())
  12. {
  13. var endX = imageSize.Width - 1;
  14. var endY = imageSize.Height - 1;
  15. paint.Color = SKColor.Parse("#99000000");
  16. paint.Style = SKPaintStyle.Fill;
  17. canvas.DrawRect(SKRect.Create(0, (float)endY - IndicatorHeight, (float)endX, (float)endY), paint);
  18. double foregroundWidth = endX;
  19. foregroundWidth *= percent;
  20. foregroundWidth /= 100;
  21. paint.Color = SKColor.Parse("#FF52B54B");
  22. canvas.DrawRect(SKRect.Create(0, (float)endY - IndicatorHeight, Convert.ToInt32(Math.Round(foregroundWidth)), (float)endY), paint);
  23. }
  24. }
  25. }
  26. }