< 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: 23
Coverable lines: 23
Total lines: 65
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        using var font = new SKFont();
 38
 039        canvas.DrawCircle(x, OffsetFromTopRightCorner, 20, paint);
 40
 041        paint.Color = new SKColor(255, 255, 255, 255);
 042        font.Size = 24;
 043        paint.IsAntialias = true;
 44
 045        var y = OffsetFromTopRightCorner + 9;
 46
 047        if (text.Length == 1)
 48        {
 049            x -= 7;
 50        }
 51
 052        if (text.Length == 2)
 53        {
 054            x -= 13;
 55        }
 056        else if (text.Length >= 3)
 57        {
 058            x -= 15;
 059            y -= 2;
 060            font.Size = 18;
 61        }
 62
 063        canvas.DrawText(text, x, y, font, paint);
 064    }
 65}