// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { [GroupOutput("Drawing")] public class SolidBezierTests { [Theory] [WithBlankImages(500, 500, PixelTypes.Rgba32)] public void FilledBezier(TestImageProvider provider) where TPixel : struct, IPixel { SixLabors.Primitives.PointF[] simplePath = { new Vector2(10, 400), new Vector2(30, 10), new Vector2(240, 30), new Vector2(300, 400) }; Color blue = Color.Blue; Color hotPink = Color.HotPink; using (Image image = provider.GetImage()) { image.Mutate(x => x.BackgroundColor(blue)); image.Mutate(x => x.Fill(hotPink.ToPixel(), new Polygon(new CubicBezierLineSegment(simplePath)))); image.DebugSave(provider); image.CompareToReferenceOutput(provider); } } [Theory] [WithBlankImages(500, 500, PixelTypes.Rgba32)] public void OverlayByFilledPolygonOpacity(TestImageProvider provider) where TPixel : struct, IPixel { SixLabors.Primitives.PointF[] simplePath = { new Vector2(10, 400), new Vector2(30, 10), new Vector2(240, 30), new Vector2(300, 400) }; var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); using (var image = provider.GetImage() as Image) { image.Mutate(x => x.BackgroundColor(Rgba32.Blue)); image.Mutate(x => x.Fill(color, new Polygon(new CubicBezierLineSegment(simplePath)))); image.DebugSave(provider); image.CompareToReferenceOutput(provider); } } } }