< Summary - Jellyfin

Information
Class: Jellyfin.Drawing.Skia.PercentPlayedDrawer
Assembly: Jellyfin.Drawing.Skia
File(s): /srv/git/jellyfin/src/Jellyfin.Drawing.Skia/PercentPlayedDrawer.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 35
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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
Process(...)100%210%

File(s)

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

#LineLine coverage
 1using System;
 2using MediaBrowser.Model.Drawing;
 3using SkiaSharp;
 4
 5namespace Jellyfin.Drawing.Skia;
 6
 7/// <summary>
 8/// Static helper class used to draw percentage-played indicators on images.
 9/// </summary>
 10public 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    {
 022        using var paint = new SKPaint();
 023        var endX = imageSize.Width - 1;
 024        var endY = imageSize.Height - 1;
 25
 026        paint.Color = SKColor.Parse("#99000000");
 027        paint.Style = SKPaintStyle.Fill;
 028        canvas.DrawRect(SKRect.Create(0, (float)endY - IndicatorHeight, endX, endY), paint);
 29
 030        double foregroundWidth = (endX * percent) / 100;
 31
 032        paint.Color = SKColor.Parse("#FF00A4DC");
 033        canvas.DrawRect(SKRect.Create(0, (float)endY - IndicatorHeight, Convert.ToInt32(foregroundWidth), endY), paint);
 034    }
 35}