aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2020-07-19 14:39:11 -0400
committerPatrick Barron <barronpm@gmail.com>2020-07-19 14:39:11 -0400
commit2569793ff08a6331dacf1513bd74c6572e28fa50 (patch)
tree325bbeec2cec51f2d9c3585349b81fddff3598b7
parentd983d65d8abdef7a71c935d134ab5d8bce3ee858 (diff)
Reuse paint objects.
-rw-r--r--Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs34
-rw-r--r--Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs52
2 files changed, 39 insertions, 47 deletions
diff --git a/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs b/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs
index 7eed5f4f7..db4f78398 100644
--- a/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs
+++ b/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs
@@ -22,31 +22,27 @@ namespace Jellyfin.Drawing.Skia
{
var x = imageSize.Width - OffsetFromTopRightCorner;
- using (var paint = new SKPaint())
+ using var paint = new SKPaint
{
- paint.Color = SKColor.Parse("#CC00A4DC");
- paint.Style = SKPaintStyle.Fill;
- canvas.DrawCircle(x, OffsetFromTopRightCorner, 20, paint);
- }
+ Color = SKColor.Parse("#CC00A4DC"),
+ Style = SKPaintStyle.Fill
+ };
- using (var paint = new SKPaint())
- {
- paint.Color = new SKColor(255, 255, 255, 255);
- paint.Style = SKPaintStyle.Fill;
+ canvas.DrawCircle(x, OffsetFromTopRightCorner, 20, paint);
- paint.TextSize = 30;
- paint.IsAntialias = true;
+ 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);
+ // 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);
+ // ask the font manager for a font with that character
+ paint.Typeface = SKFontManager.Default.MatchCharacter(emojiChar);
- canvas.DrawText(Text, (float)x - 20, OffsetFromTopRightCorner + 12, paint);
- }
+ canvas.DrawText(Text, (float)x - 20, OffsetFromTopRightCorner + 12, paint);
}
}
}
diff --git a/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs b/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs
index cf3dbde2c..58f887c96 100644
--- a/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs
+++ b/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs
@@ -28,41 +28,37 @@ namespace Jellyfin.Drawing.Skia
var x = imageSize.Width - OffsetFromTopRightCorner;
var text = count.ToString(CultureInfo.InvariantCulture);
- using (var paint = new SKPaint())
+ using var paint = new SKPaint
{
- paint.Color = SKColor.Parse("#CC00A4DC");
- paint.Style = SKPaintStyle.Fill;
- canvas.DrawCircle(x, OffsetFromTopRightCorner, 20, paint);
- }
-
- using (var paint = new SKPaint())
- {
- paint.Color = new SKColor(255, 255, 255, 255);
- paint.Style = SKPaintStyle.Fill;
+ Color = SKColor.Parse("#CC00A4DC"),
+ Style = SKPaintStyle.Fill
+ };
- paint.TextSize = 24;
- paint.IsAntialias = true;
+ canvas.DrawCircle(x, OffsetFromTopRightCorner, 20, paint);
- var y = OffsetFromTopRightCorner + 9;
+ paint.Color = new SKColor(255, 255, 255, 255);
+ paint.TextSize = 24;
+ paint.IsAntialias = true;
- if (text.Length == 1)
- {
- x -= 7;
- }
+ var y = OffsetFromTopRightCorner + 9;
- if (text.Length == 2)
- {
- x -= 13;
- }
- else if (text.Length >= 3)
- {
- x -= 15;
- y -= 2;
- paint.TextSize = 18;
- }
+ if (text.Length == 1)
+ {
+ x -= 7;
+ }
- canvas.DrawText(text, x, y, paint);
+ if (text.Length == 2)
+ {
+ x -= 13;
+ }
+ else if (text.Length >= 3)
+ {
+ x -= 15;
+ y -= 2;
+ paint.TextSize = 18;
}
+
+ canvas.DrawText(text, x, y, paint);
}
}
}