diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-04-08 10:38:02 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-04-08 10:38:02 -0400 |
| commit | 4820fe80971c83cde97a445e45b9e0b1952b0d90 (patch) | |
| tree | 4009bb413065f08471a9c7546e4330fe1d8713c9 /Emby.Drawing/ImageMagick/UnplayedCountIndicator.cs | |
| parent | 78e96917e12abb963301957607da4a738f27df58 (diff) | |
added drawing project
Diffstat (limited to 'Emby.Drawing/ImageMagick/UnplayedCountIndicator.cs')
| -rw-r--r-- | Emby.Drawing/ImageMagick/UnplayedCountIndicator.cs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/Emby.Drawing/ImageMagick/UnplayedCountIndicator.cs b/Emby.Drawing/ImageMagick/UnplayedCountIndicator.cs new file mode 100644 index 000000000..dd25004d6 --- /dev/null +++ b/Emby.Drawing/ImageMagick/UnplayedCountIndicator.cs @@ -0,0 +1,70 @@ +using ImageMagickSharp; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Model.Drawing; +using System.Globalization; + +namespace Emby.Drawing.ImageMagick +{ + public class UnplayedCountIndicator + { + private const int OffsetFromTopRightCorner = 38; + + private readonly IApplicationPaths _appPaths; + + public UnplayedCountIndicator(IApplicationPaths appPaths) + { + _appPaths = appPaths; + } + + public void DrawUnplayedCountIndicator(MagickWand wand, ImageSize imageSize, int count) + { + var x = imageSize.Width - OffsetFromTopRightCorner; + var text = count.ToString(CultureInfo.InvariantCulture); + + using (var draw = new DrawingWand()) + { + using (PixelWand pixel = new PixelWand()) + { + pixel.Color = "#52B54B"; + pixel.Opacity = 0.2; + draw.FillColor = pixel; + draw.DrawCircle(x, OffsetFromTopRightCorner, x - 20, OffsetFromTopRightCorner - 20); + + pixel.Opacity = 0; + pixel.Color = "white"; + draw.FillColor = pixel; + draw.Font = PlayedIndicatorDrawer.ExtractFont("robotoregular.ttf", _appPaths); + draw.FontStyle = FontStyleType.NormalStyle; + draw.TextAlignment = TextAlignType.CenterAlign; + draw.FontWeight = FontWeightType.RegularStyle; + draw.TextAntialias = true; + + var fontSize = 30; + var y = OffsetFromTopRightCorner + 11; + + if (text.Length == 1) + { + x += 1; + } + else if (text.Length == 2) + { + x += 1; + } + else if (text.Length >= 3) + { + //x += 1; + y -= 2; + fontSize = 24; + } + + draw.FontSize = fontSize; + draw.DrawAnnotation(x, y, text); + + draw.FillColor = pixel; + wand.CurrentImage.DrawImage(draw); + } + + } + } + } +} |
