< Summary - Jellyfin

Information
Class: Jellyfin.Drawing.Skia.UnplayedCountIndicator
Assembly: Jellyfin.Drawing.Skia
File(s): /srv/git/jellyfin/src/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 22
Coverable lines: 22
Total lines: 63
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
DrawUnplayedCountIndicator(...)0%4260%

File(s)

/srv/git/jellyfin/src/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs

#LineLine coverage
 1using System.Globalization;
 2using MediaBrowser.Model.Drawing;
 3using SkiaSharp;
 4
 5namespace Jellyfin.Drawing.Skia;
 6
 7/// <summary>
 8/// Static helper class for drawing unplayed count indicators.
 9/// </summary>
 10public static class UnplayedCountIndicator
 11{
 12    /// <summary>
 13    /// The x-offset used when drawing an unplayed count indicator.
 14    /// </summary>
 15    private const int OffsetFromTopRightCorner = 38;
 16
 17    /// <summary>
 18    /// Draw an unplayed count indicator in the top right corner of a canvas.
 19    /// </summary>
 20    /// <param name="canvas">The canvas to draw the indicator on.</param>
 21    /// <param name="imageSize">
 22    /// The dimensions of the image to draw the indicator on. The width is used to determine the x-position of the
 23    /// indicator.
 24    /// </param>
 25    /// <param name="count">The number to draw in the indicator.</param>
 26    public static void DrawUnplayedCountIndicator(SKCanvas canvas, ImageDimensions imageSize, int count)
 27    {
 028        var x = imageSize.Width - OffsetFromTopRightCorner;
 029        var text = count.ToString(CultureInfo.InvariantCulture);
 30
 031        using var paint = new SKPaint
 032        {
 033            Color = SKColor.Parse("#CC00A4DC"),
 034            Style = SKPaintStyle.Fill
 035        };
 36
 037        canvas.DrawCircle(x, OffsetFromTopRightCorner, 20, paint);
 38
 039        paint.Color = new SKColor(255, 255, 255, 255);
 040        paint.TextSize = 24;
 041        paint.IsAntialias = true;
 42
 043        var y = OffsetFromTopRightCorner + 9;
 44
 045        if (text.Length == 1)
 46        {
 047            x -= 7;
 48        }
 49
 050        if (text.Length == 2)
 51        {
 052            x -= 13;
 53        }
 054        else if (text.Length >= 3)
 55        {
 056            x -= 15;
 057            y -= 2;
 058            paint.TextSize = 18;
 59        }
 60
 061        canvas.DrawText(text, x, y, paint);
 062    }
 63}