public async Task DrawPlayedIndicator(MagickWand wand, ImageSize imageSize) { var x = imageSize.Width - OffsetFromTopRightCorner; 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 = await DownloadFont("webdings.ttf", "https://github.com/MediaBrowser/Emby.Resources/raw/master/fonts/webdings.ttf", _appPaths, _iHttpClient, _fileSystem).ConfigureAwait(false); draw.FontSize = FontSize; draw.FontStyle = FontStyleType.NormalStyle; draw.TextAlignment = TextAlignType.CenterAlign; draw.FontWeight = FontWeightType.RegularStyle; draw.TextAntialias = true; draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a"); draw.FillColor = pixel; wand.CurrentImage.DrawImage(draw); } } }
public void DrawPlayedIndicator(MagickWand wand, ImageSize imageSize) { var x = imageSize.Width - OffsetFromTopRightCorner; 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 = ExtractFont("webdings.ttf", _appPaths); draw.FontSize = FontSize; draw.FontStyle = FontStyleType.NormalStyle; draw.TextAlignment = TextAlignType.CenterAlign; draw.FontWeight = FontWeightType.RegularStyle; draw.TextAntialias = true; draw.DrawAnnotation(x + 4, OffsetFromTopRightCorner + 14, "a"); draw.FillColor = pixel; wand.CurrentImage.DrawImage(draw); } } }
/// <summary> A MagickWand extension method that draw circle. </summary> /// <param name="wand"> The wand to act on. </param> /// <param name="x"> The x coordinate. </param> /// <param name="y"> The y coordinate. </param> /// <param name="p"> The double to process. </param> /// <param name="strokeColor"> The stroke color. </param> /// <param name="fillcolor"> The fillcolor. </param> internal static void DrawCircle(this ImageWand wand, double x, double y, double p, PixelWand strokeColor, PixelWand fillcolor) { using (var draw = new DrawingWand()) { draw.StrokeColor = strokeColor; draw.FillColor = fillcolor; draw.DrawCircle(x + p, y + p, x + p, y + p * 2); wand.DrawImage(draw); } }
/// <summary> A MagickWand extension method that draw circle. </summary> /// <param name="wand"> The wand to act on. </param> /// <param name="ox"> The ox. </param> /// <param name="oy"> The oy. </param> /// <param name="px"> The px. </param> /// <param name="py"> The py. </param> /// <param name="strokeColor"> The stroke color. </param> /// <param name="fillcolor"> The fillcolor. </param> internal static void DrawCircle(this ImageWand wand, double ox, double oy, double px, double py, PixelWand strokeColor, PixelWand fillcolor) { using (var draw = new DrawingWand()) { draw.StrokeColor = strokeColor; draw.FillColor = fillcolor; draw.DrawCircle(ox, oy, px, py); wand.DrawImage(draw); } }
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, _fileSystem); 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); } } }
public void DrawingWandCircleTest() { using (var wand = new MagickWand(TestImageBackdrop)) { //wand.NewImage(400, 200, new PixelWand("white")); //wand.OpenImage(TestImageBackdrop); using (var draw = new DrawingWand()) { using (PixelWand pixel = new PixelWand()) { pixel.Color = "red"; draw.StrokeColor = pixel; pixel.Color = "black"; pixel.Opacity = 0.3; draw.FillColor = pixel; draw.DrawCircle(400, 400, 300, 300); pixel.Color = "transparent"; draw.StrokeColor = pixel; pixel.Color = "white"; draw.FillColor = pixel; draw.Font = "Verdana"; draw.FontSize = 120; draw.FontStyle = FontStyleType.NormalStyle; draw.TextAlignment = TextAlignType.LeftAlign; draw.FontWeight = FontWeightType.BoldStyle; draw.TextAntialias = true; draw.DrawAnnotation(10, 100, "Media Browser"); draw.FillColor = pixel; wand.CurrentImage.DrawImage(draw); } } //Debug.WriteLine(wand.GetNumberImages()); //wand.Image.TrimImage(10); wand.SaveImage(Path.Combine(SaveDirectory, "logo_extent.jpg")); } }