2017-05-09 19:53:46 +00:00
|
|
|
using MediaBrowser.Model.Drawing;
|
2019-01-13 19:16:43 +00:00
|
|
|
using SkiaSharp;
|
2017-05-09 19:53:46 +00:00
|
|
|
|
2019-01-26 19:43:13 +00:00
|
|
|
namespace Jellyfin.Drawing.Skia
|
2017-05-09 19:53:46 +00:00
|
|
|
{
|
2019-01-20 13:25:13 +00:00
|
|
|
public static class PlayedIndicatorDrawer
|
2017-05-09 19:53:46 +00:00
|
|
|
{
|
|
|
|
private const int OffsetFromTopRightCorner = 38;
|
|
|
|
|
2019-01-26 12:16:47 +00:00
|
|
|
public static void DrawPlayedIndicator(SKCanvas canvas, ImageDimensions imageSize)
|
2017-05-09 19:53:46 +00:00
|
|
|
{
|
|
|
|
var x = imageSize.Width - OffsetFromTopRightCorner;
|
|
|
|
|
|
|
|
using (var paint = new SKPaint())
|
|
|
|
{
|
|
|
|
paint.Color = SKColor.Parse("#CC52B54B");
|
|
|
|
paint.Style = SKPaintStyle.Fill;
|
|
|
|
canvas.DrawCircle((float)x, OffsetFromTopRightCorner, 20, paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
using (var paint = new SKPaint())
|
|
|
|
{
|
|
|
|
paint.Color = new SKColor(255, 255, 255, 255);
|
|
|
|
paint.Style = SKPaintStyle.Fill;
|
|
|
|
|
2017-11-21 22:14:56 +00:00
|
|
|
paint.TextSize = 30;
|
|
|
|
paint.IsAntialias = true;
|
2017-05-09 19:53:46 +00:00
|
|
|
|
2017-11-21 22:14:56 +00:00
|
|
|
var text = "✔️";
|
|
|
|
var emojiChar = StringUtilities.GetUnicodeCharacterCode(text, SKTextEncoding.Utf32);
|
|
|
|
// or:
|
|
|
|
//var emojiChar = 0x1F680;
|
2017-05-09 19:53:46 +00:00
|
|
|
|
2017-11-21 22:14:56 +00:00
|
|
|
// ask the font manager for a font with that character
|
|
|
|
var fontManager = SKFontManager.Default;
|
|
|
|
var emojiTypeface = fontManager.MatchCharacter(emojiChar);
|
2017-05-09 19:53:46 +00:00
|
|
|
|
2017-11-21 22:14:56 +00:00
|
|
|
paint.Typeface = emojiTypeface;
|
2017-05-09 19:53:46 +00:00
|
|
|
|
2019-01-13 19:16:43 +00:00
|
|
|
canvas.DrawText(text, (float)x - 20, OffsetFromTopRightCorner + 12, paint);
|
2017-05-09 19:53:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|