aboutsummaryrefslogtreecommitdiff
path: root/src/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs')
-rw-r--r--src/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs b/src/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs
new file mode 100644
index 000000000..2a3729942
--- /dev/null
+++ b/src/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs
@@ -0,0 +1,48 @@
+using MediaBrowser.Model.Drawing;
+using SkiaSharp;
+
+namespace Jellyfin.Drawing.Skia
+{
+ /// <summary>
+ /// Static helper class for drawing 'played' indicators.
+ /// </summary>
+ public static class PlayedIndicatorDrawer
+ {
+ private const int OffsetFromTopRightCorner = 38;
+
+ /// <summary>
+ /// Draw a 'played' 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>
+ public static void DrawPlayedIndicator(SKCanvas canvas, ImageDimensions imageSize)
+ {
+ var x = imageSize.Width - OffsetFromTopRightCorner;
+
+ using var paint = new SKPaint
+ {
+ Color = SKColor.Parse("#CC00A4DC"),
+ Style = SKPaintStyle.Fill
+ };
+
+ canvas.DrawCircle(x, OffsetFromTopRightCorner, 20, paint);
+
+ paint.Color = new SKColor(255, 255, 255, 255);
+ paint.TextSize = 30;
+ paint.IsAntialias = true;
+
+ // or:
+ // var emojiChar = 0x1F680;
+ const string Text = "✔️";
+ var emojiChar = StringUtilities.GetUnicodeCharacterCode(Text, SKTextEncoding.Utf32);
+
+ // ask the font manager for a font with that character
+ paint.Typeface = SKFontManager.Default.MatchCharacter(emojiChar);
+
+ canvas.DrawText(Text, (float)x - 12, OffsetFromTopRightCorner + 12, paint);
+ }
+ }
+}