| | 1 | | using System; |
| | 2 | | using MediaBrowser.Model.Drawing; |
| | 3 | | using SkiaSharp; |
| | 4 | |
|
| | 5 | | namespace Jellyfin.Drawing.Skia; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// Static helper class used to draw percentage-played indicators on images. |
| | 9 | | /// </summary> |
| | 10 | | public static class PercentPlayedDrawer |
| | 11 | | { |
| | 12 | | private const int IndicatorHeight = 8; |
| | 13 | |
|
| | 14 | | /// <summary> |
| | 15 | | /// Draw a percentage played indicator on a canvas. |
| | 16 | | /// </summary> |
| | 17 | | /// <param name="canvas">The canvas to draw the indicator on.</param> |
| | 18 | | /// <param name="imageSize">The size of the image being drawn on.</param> |
| | 19 | | /// <param name="percent">The percentage played to display with the indicator.</param> |
| | 20 | | public static void Process(SKCanvas canvas, ImageDimensions imageSize, double percent) |
| | 21 | | { |
| 0 | 22 | | using var paint = new SKPaint(); |
| 0 | 23 | | var endX = imageSize.Width - 1; |
| 0 | 24 | | var endY = imageSize.Height - 1; |
| | 25 | |
|
| 0 | 26 | | paint.Color = SKColor.Parse("#99000000"); |
| 0 | 27 | | paint.Style = SKPaintStyle.Fill; |
| 0 | 28 | | canvas.DrawRect(SKRect.Create(0, (float)endY - IndicatorHeight, endX, endY), paint); |
| | 29 | |
|
| 0 | 30 | | double foregroundWidth = (endX * percent) / 100; |
| | 31 | |
|
| 0 | 32 | | paint.Color = SKColor.Parse("#FF00A4DC"); |
| 0 | 33 | | canvas.DrawRect(SKRect.Create(0, (float)endY - IndicatorHeight, Convert.ToInt32(foregroundWidth), endY), paint); |
| 0 | 34 | | } |
| | 35 | | } |