diff options
Diffstat (limited to 'src/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs')
| -rw-r--r-- | src/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs | 91 |
1 files changed, 45 insertions, 46 deletions
diff --git a/src/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs b/src/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs index 58f887c96..456b84b8c 100644 --- a/src/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs +++ b/src/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs @@ -2,63 +2,62 @@ using System.Globalization; using MediaBrowser.Model.Drawing; using SkiaSharp; -namespace Jellyfin.Drawing.Skia +namespace Jellyfin.Drawing.Skia; + +/// <summary> +/// Static helper class for drawing unplayed count indicators. +/// </summary> +public static class UnplayedCountIndicator { /// <summary> - /// Static helper class for drawing unplayed count indicators. + /// The x-offset used when drawing an unplayed count indicator. + /// </summary> + private const int OffsetFromTopRightCorner = 38; + + /// <summary> + /// Draw an unplayed count indicator in the top right corner of a canvas. /// </summary> - public static class UnplayedCountIndicator + /// <param name="canvas">The canvas to draw the indicator on.</param> + /// <param name="imageSize"> + /// The dimensions of the image to draw the indicator on. The width is used to determine the x-position of the + /// indicator. + /// </param> + /// <param name="count">The number to draw in the indicator.</param> + public static void DrawUnplayedCountIndicator(SKCanvas canvas, ImageDimensions imageSize, int count) { - /// <summary> - /// The x-offset used when drawing an unplayed count indicator. - /// </summary> - private const int OffsetFromTopRightCorner = 38; + var x = imageSize.Width - OffsetFromTopRightCorner; + var text = count.ToString(CultureInfo.InvariantCulture); - /// <summary> - /// Draw an unplayed count indicator in the top right corner of a canvas. - /// </summary> - /// <param name="canvas">The canvas to draw the indicator on.</param> - /// <param name="imageSize"> - /// The dimensions of the image to draw the indicator on. The width is used to determine the x-position of the - /// indicator. - /// </param> - /// <param name="count">The number to draw in the indicator.</param> - public static void DrawUnplayedCountIndicator(SKCanvas canvas, ImageDimensions imageSize, int count) + using var paint = new SKPaint { - var x = imageSize.Width - OffsetFromTopRightCorner; - var text = count.ToString(CultureInfo.InvariantCulture); - - using var paint = new SKPaint - { - Color = SKColor.Parse("#CC00A4DC"), - Style = SKPaintStyle.Fill - }; - - canvas.DrawCircle(x, OffsetFromTopRightCorner, 20, paint); + Color = SKColor.Parse("#CC00A4DC"), + Style = SKPaintStyle.Fill + }; - paint.Color = new SKColor(255, 255, 255, 255); - paint.TextSize = 24; - paint.IsAntialias = true; + canvas.DrawCircle(x, OffsetFromTopRightCorner, 20, paint); - var y = OffsetFromTopRightCorner + 9; + paint.Color = new SKColor(255, 255, 255, 255); + paint.TextSize = 24; + paint.IsAntialias = true; - if (text.Length == 1) - { - x -= 7; - } + var y = OffsetFromTopRightCorner + 9; - if (text.Length == 2) - { - x -= 13; - } - else if (text.Length >= 3) - { - x -= 15; - y -= 2; - paint.TextSize = 18; - } + if (text.Length == 1) + { + x -= 7; + } - canvas.DrawText(text, x, y, paint); + if (text.Length == 2) + { + x -= 13; } + else if (text.Length >= 3) + { + x -= 15; + y -= 2; + paint.TextSize = 18; + } + + canvas.DrawText(text, x, y, paint); } } |
