You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
45 lines
1.4 KiB
8 years ago
|
using MediaBrowser.Model.Drawing;
|
||
6 years ago
|
using SkiaSharp;
|
||
8 years ago
|
|
||
6 years ago
|
namespace Jellyfin.Drawing.Skia
|
||
8 years ago
|
{
|
||
6 years ago
|
public static class PlayedIndicatorDrawer
|
||
8 years ago
|
{
|
||
|
private const int OffsetFromTopRightCorner = 38;
|
||
|
|
||
6 years ago
|
public static void DrawPlayedIndicator(SKCanvas canvas, ImageDimensions imageSize)
|
||
8 years ago
|
{
|
||
|
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;
|
||
|
|
||
7 years ago
|
paint.TextSize = 30;
|
||
|
paint.IsAntialias = true;
|
||
8 years ago
|
|
||
7 years ago
|
var text = "✔️";
|
||
|
var emojiChar = StringUtilities.GetUnicodeCharacterCode(text, SKTextEncoding.Utf32);
|
||
|
// or:
|
||
|
//var emojiChar = 0x1F680;
|
||
8 years ago
|
|
||
7 years ago
|
// ask the font manager for a font with that character
|
||
|
var fontManager = SKFontManager.Default;
|
||
|
var emojiTypeface = fontManager.MatchCharacter(emojiChar);
|
||
8 years ago
|
|
||
7 years ago
|
paint.Typeface = emojiTypeface;
|
||
8 years ago
|
|
||
6 years ago
|
canvas.DrawText(text, (float)x - 20, OffsetFromTopRightCorner + 12, paint);
|
||
8 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|