public void BrushAppliesBeforPenDefaultOptions() { this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), Vector2.Zero); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(2, this.img.ProcessorApplications.Count); Assert.IsType <FillRegionProcessor <Rgba32> >(this.img.ProcessorApplications[0].processor); Assert.IsType <DrawPathProcessor <Rgba32> >(this.img.ProcessorApplications[1].processor); }
public void DrawForEachACharachterWhenPenSet() { this.operations.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), this.path, new TextGraphicsOptions(true)); var processor = this.Verify <FillRegionProcessor <Rgba32> >(0); this.Verify <FillRegionProcessor <Rgba32> >(1); this.Verify <FillRegionProcessor <Rgba32> >(2); }
public void DrawForEachACharacterWhenPenSetAndNotBrushDefaultOptions() { this.operations.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero); var processor = this.Verify <DrawTextProcessor>(0); Assert.Equal(this.textOptions, processor.Options.TextOptions); Assert.Equal(this.options, processor.Options.GraphicsOptions); }
public void DrawForEachACharachterWhenPenSetDefaultOptions() { this.operations.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), this.path); FillRegionProcessor <Rgba32> processor = this.Verify <FillRegionProcessor <Rgba32> >(0); this.Verify <FillRegionProcessor <Rgba32> >(1); this.Verify <FillRegionProcessor <Rgba32> >(2); }
public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions() { this.operations.DrawText("123", this.Font, null, Pens.Dash(Rgba32.Red, 1), Vector2.Zero); var processor = this.Verify <FillRegionProcessor <Rgba32> >(0); this.Verify <FillRegionProcessor <Rgba32> >(1); this.Verify <FillRegionProcessor <Rgba32> >(2); }
public void DrawForEachACharacterWhenPenSet() { this.operations.DrawText(this.otherTextOptions, "123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero); var processor = this.Verify <DrawTextProcessor>(0); Assert.NotEqual(this.textOptions, processor.Options.TextOptions); Assert.NotEqual(this.options, processor.Options.GraphicsOptions); }
public void DrawForEachACharacterWhenPenSetAndNotBrush() { this.operations.DrawText( new TextGraphicsOptions(true), "123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero); this.Verify <DrawTextProcessor>(0); }
public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSetDefaultOptions() { this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), this.path); var processor = this.Verify <FillRegionProcessor <Rgba32> >(0); this.Verify <FillRegionProcessor <Rgba32> >(1); this.Verify <FillRegionProcessor <Rgba32> >(2); this.Verify <FillRegionProcessor <Rgba32> >(3); this.Verify <FillRegionProcessor <Rgba32> >(4); this.Verify <FillRegionProcessor <Rgba32> >(5); }
public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSet() { this.img.DrawText( "123", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), path, new TextGraphicsOptions(true)); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(6, this.img.ProcessorApplications.Count); }
public void DrawForEachACharachterWhenPenSetAndNotBrush() { this.img.DrawText( "123", this.Font, null, Pens.Dash(Rgba32.Red, 1), path, new TextGraphicsOptions(true)); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied Assert.IsType <FillRegionProcessor <Rgba32> >(this.img.ProcessorApplications[0].processor); }
public void DrawForEachACharacterWhenPenSetDefaultOptions() { this.operations.DrawText("123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero); var processor = this.Verify <DrawTextProcessor>(0); Assert.Equal("123", processor.Text); Assert.Equal(this.Font, processor.Font); var penBrush = Assert.IsType <SolidBrush>(processor.Pen.StrokeFill); Assert.Equal(Color.Red, penBrush.Color); Assert.Equal(1, processor.Pen.StrokeWidth); Assert.Equal(PointF.Empty, processor.Location); }
public void DrawForEachACharachterWhenPenSetAndNotBrush() { this.img.DrawText( "123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied Assert.IsType <DrawPathProcessor <Color> >(this.img.ProcessorApplications[0].processor); }
public void BrushAppliesBeforPen() { this.operations.DrawText( new TextGraphicsOptions(true), "1", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), this.path); var processor = this.Verify <FillRegionProcessor <Rgba32> >(0); this.Verify <FillRegionProcessor <Rgba32> >(1); }
public void DrawComplexPolygon <TPixel>(TestImageProvider <TPixel> provider, bool overlap, bool transparent, bool dashed) where TPixel : unmanaged, IPixel <TPixel> { var simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300))); var hole1 = new Polygon(new LinearLineSegment( new Vector2(37, 85), overlap ? new Vector2(130, 40) : new Vector2(93, 85), new Vector2(65, 137))); IPath clipped = simplePath.Clip(hole1); Rgba32 colorRgba = Color.White; if (transparent) { colorRgba.A = 150; } Color color = colorRgba; string testDetails = string.Empty; if (overlap) { testDetails += "_Overlap"; } if (transparent) { testDetails += "_Transparent"; } if (dashed) { testDetails += "_Dashed"; } Pen pen = dashed ? Pens.Dash(color, 5f) : Pens.Solid(color, 5f); provider.RunValidatingProcessorTest( x => x.Draw(pen, clipped), testDetails, appendPixelTypeToFileName: false, appendSourceFileOrDescription: false); }
public void BrushAppliesBeforPen() { this.img.DrawText( "1", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), path, new TextGraphicsOptions(true)); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(2, this.img.ProcessorApplications.Count); Assert.IsType <FillRegionProcessor <Rgba32> >(this.img.ProcessorApplications[0].processor); Assert.IsType <FillRegionProcessor <Rgba32> >(this.img.ProcessorApplications[1].processor); }
public void BrushAppliesBeforPen() { this.img.DrawText( "1", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(2, this.img.ProcessorApplications.Count); Assert.IsType <FillRegionProcessor <Color> >(this.img.ProcessorApplications[0].processor); Assert.IsType <DrawPathProcessor <Color> >(this.img.ProcessorApplications[1].processor); }
public void ImageShouldBeOverlayedByPathDashed() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); using (var image = new Image <Rgba32>(500, 500)) { image.Mutate(x => x.BackgroundColor(Rgba32.Blue)); image.Mutate(x => x.DrawLines(Pens.Dash(Rgba32.HotPink, 5), new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) })); image.Save($"{path}/Dashed.png"); } }
private static MemeTemplate GetMemeTemplate() { var font = MemeFonts.GetDefaultFont(); var textRenderer = new TextInputRenderer(font, Pens.Dash <Rgba32>(Rgba32.Black, 1), Brushes.Solid(Rgba32.Black), HorizontalAlignment.Center, VerticalAlignment.Center, false); var disappointment = new InputFieldBuilder() .WithName("Baby") .WithVertices(new Point(115, 720), new Point(584, 720), new Point(115, 884), new Point(584, 884)) .WithRenderer(textRenderer) .WithPadding(0.03) .Build(); return(new MemeTemplateBuilder("TestData/Disappointment.png") .WithName("Disappointment") .WithDescription("Free disappointment") .WithInputField(disappointment) .Build()); }
public void ImageShouldBeOverlayedByPathDashed() { string path = CreateOutputDirectory("Drawing", "Lines"); var image = new Image(500, 500); using (FileStream output = File.OpenWrite($"{path}/Dashed.png")) { image .BackgroundColor(Color.Blue) .DrawLines(Pens.Dash(Color.HotPink, 5), new[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) }) .Save(output); } }
public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSet() { this.operations.DrawText( "123", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); var processor = this.Verify <FillRegionProcessor <Rgba32> >(0); this.Verify <FillRegionProcessor <Rgba32> >(1); this.Verify <FillRegionProcessor <Rgba32> >(2); this.Verify <FillRegionProcessor <Rgba32> >(3); this.Verify <FillRegionProcessor <Rgba32> >(4); this.Verify <FillRegionProcessor <Rgba32> >(5); }
public void ImageShouldBeOverlayedByPolygonOutlineDashed() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); var simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300))); var hole1 = new Polygon(new LinearLineSegment( new Vector2(37, 85), new Vector2(93, 85), new Vector2(65, 137))); using (var image = new Image <Rgba32>(500, 500)) { image.Mutate(x => x.BackgroundColor(Rgba32.Blue)); image.Mutate(x => x.Draw(Pens.Dash(Rgba32.HotPink, 5), simplePath.Clip(hole1))); image.Save($"{path}/Dashed.png"); } }
public void DrawForEachACharacterWhenPenSetAndFillFroEachWhenBrushSet() { this.operations.DrawText( new TextGraphicsOptions(true), "123", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero); var processor = this.Verify <DrawTextProcessor>(0); Assert.Equal("123", processor.Text); Assert.Equal(this.Font, processor.Font); var brush = Assert.IsType <SolidBrush>(processor.Brush); Assert.Equal(Color.Red, brush.Color); Assert.Equal(PointF.Empty, processor.Location); var penBrush = Assert.IsType <SolidBrush>(processor.Pen.StrokeFill); Assert.Equal(Color.Red, penBrush.Color); Assert.Equal(1, processor.Pen.StrokeWidth); }
public void ImageShouldBeOverlayedByPolygonOutlineDashed() { string path = CreateOutputDirectory("Drawing", "LineComplexPolygon"); var simplePath = new LinearPolygon( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300)); var hole1 = new LinearPolygon( new Vector2(37, 85), new Vector2(93, 85), new Vector2(65, 137)); var image = new Image(500, 500); using (FileStream output = File.OpenWrite($"{path}/Dashed.png")) { image .BackgroundColor(Color.Blue) .DrawPolygon(Pens.Dash(Color.HotPink, 5), new ComplexPolygon(simplePath, hole1)) .Save(output); } }
public static IPen GetPen(this Cmdlet cmdlet, Pen penType, float width, string colorString) { Rgba32 rgbaColor = cmdlet.ParseColor(colorString); Color color = new Color(rgbaColor); switch (penType) { case Pen.Dash: return(Pens.Dash(color, width)); case Pen.DashDot: return(Pens.DashDot(color, width)); case Pen.DashDotDot: return(Pens.DashDotDot(color, width)); case Pen.Dot: return(Pens.Dot(color, width)); default: return(Pens.Solid(color, width)); } }
public void ImageShouldBeOverlayedByPolygonOutlineDashed() { string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon"); Polygon simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300))); Polygon hole1 = new Polygon(new LinearLineSegment( new Vector2(37, 85), new Vector2(93, 85), new Vector2(65, 137))); using (Image <Rgba32> image = new Image <Rgba32>(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Dashed.png")) { image .BackgroundColor(Rgba32.Blue) .Draw(Pens.Dash(Rgba32.HotPink, 5), simplePath.Clip(hole1)) .Save(output); } } }
/// <summary> /// Renderes the given historic coverages as PNG image. /// </summary> /// <param name="historicCoverages">The historic coverages.</param> /// <returns>The image in PNG format.</returns> public static byte[] RenderHistoryChart(IReadOnlyList <HistoricCoverage> historicCoverages) { using (Image <Rgba32> image = new Image <Rgba32>(1450, 150)) using (MemoryStream output = new MemoryStream()) { var grayPen = Pens.Dash(Color.LightGray, 1); var redPen = Pens.Solid(Color.ParseHex("cc0000"), 2); var bluePen = Pens.Solid(Color.ParseHex("1c2298"), 2); var redBrush = Brushes.Solid(Color.ParseHex("cc0000")); var blueBrush = Brushes.Solid(Color.ParseHex("1c2298")); int numberOfLines = historicCoverages.Count; if (numberOfLines == 1) { numberOfLines = 2; } float totalWidth = 1445 - 50; float width = totalWidth / (numberOfLines - 1); float totalHeight = 115 - 15; image.Mutate(ctx => { ctx.Fill(Color.White); ctx.DrawLines(grayPen, new PointF(50, 115), new PointF(1445, 115)); ctx.DrawLines(grayPen, new PointF(50, 90), new PointF(1445, 90)); ctx.DrawLines(grayPen, new PointF(50, 65), new PointF(1445, 65)); ctx.DrawLines(grayPen, new PointF(50, 40), new PointF(1445, 40)); ctx.DrawLines(grayPen, new PointF(50, 15), new PointF(1445, 15)); for (int i = 0; i < numberOfLines; i++) { ctx.DrawLines(grayPen, new PointF(50 + (i * width), 15), new PointF(50 + (i * width), 115)); } for (int i = 1; i < historicCoverages.Count; i++) { float x1 = 50 + ((i - 1) * width); float y1 = 15 + (((100 - (float)historicCoverages[i - 1].CoverageQuota.GetValueOrDefault()) * totalHeight) / 100); float x2 = 50 + (i * width); float y2 = 15 + (((100 - (float)historicCoverages[i].CoverageQuota.GetValueOrDefault()) * totalHeight) / 100); ctx.DrawLines(redPen, new PointF(x1, y1), new PointF(x2, y2)); } if (historicCoverages.Any(h => h.BranchCoverageQuota.HasValue)) { for (int i = 1; i < historicCoverages.Count; i++) { float x1 = 50 + ((i - 1) * width); float y1 = 15 + (((100 - (float)historicCoverages[i - 1].BranchCoverageQuota.GetValueOrDefault()) * totalHeight) / 100); float x2 = 50 + (i * width); float y2 = 15 + (((100 - (float)historicCoverages[i].BranchCoverageQuota.GetValueOrDefault()) * totalHeight) / 100); ctx.DrawLines(bluePen, new PointF(x1, y1), new PointF(x2, y2)); } } for (int i = 0; i < historicCoverages.Count; i++) { float x1 = 50 + (i * width); float y1 = 15 + (((100 - (float)historicCoverages[i].CoverageQuota.GetValueOrDefault()) * totalHeight) / 100); ctx.Fill(redBrush, new EllipsePolygon(x1, y1, 3)); } if (historicCoverages.Any(h => h.BranchCoverageQuota.HasValue)) { for (int i = 0; i < historicCoverages.Count; i++) { float x1 = 50 + (i * width); float y1 = 15 + (((100 - (float)historicCoverages[i].BranchCoverageQuota.GetValueOrDefault()) * totalHeight) / 100); ctx.Fill(blueBrush, new EllipsePolygon(x1, y1, 3)); } } try { var font = SystemFonts.CreateFont("Arial", 11, FontStyle.Regular); var textGraphicsOptions = new TextGraphicsOptions(); textGraphicsOptions.TextOptions.HorizontalAlignment = HorizontalAlignment.Right; ctx.DrawText(textGraphicsOptions, "100", font, Color.Gray, new PointF(38, 5)); ctx.DrawText(textGraphicsOptions, "75", font, Color.Gray, new PointF(38, 30)); ctx.DrawText(textGraphicsOptions, "50", font, Color.Gray, new PointF(38, 55)); ctx.DrawText(textGraphicsOptions, "25", font, Color.Gray, new PointF(38, 80)); ctx.DrawText(textGraphicsOptions, "0", font, Color.Gray, new PointF(38, 105)); } catch (SixLabors.Fonts.Exceptions.FontFamilyNotFoundException) { // Font 'Arial' may not be present on Linux } }); image.Save(output, new PngEncoder()); return(output.ToArray()); } }
public void DrawForEachACharachterWhenPenSet() { this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero); var processor = this.Verify <DrawTextProcessor <Rgba32> >(0); }
/// <summary> /// Create a pen with a 'Dash' drawing patterns /// </summary> /// <param name="color">The color.</param> /// <param name="width">The width.</param> /// <returns>The Pen</returns> public static Pen Dash(Color color, float width) => new Pen(Pens <Color> .Dash(color, width));
/// <summary> /// Create a pen with a 'Dash' drawing patterns /// </summary> /// <param name="brush">The brush.</param> /// <param name="width">The width.</param> /// <returns>The Pen</returns> public static Pen Dash(IBrush <Color> brush, float width) => new Pen(Pens <Color> .Dash(brush, width));
public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions() { this.operations.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero); var processor = this.Verify <DrawTextProcessor>(0); }