// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Drawing { using System; /// /// Extension methods for helping to bridge Shaper2D and ImageSharp primitives. /// internal static class RectangleExtensions { /// /// Converts a Shaper2D to an ImageSharp by creating a the entirely surrounds the source. /// /// The image this method extends. /// A representation of this public static Rectangle Convert(this SixLabors.Shapes.Rectangle source) { int left = (int)MathF.Floor(source.Left); int right = (int)MathF.Ceiling(source.Right); int top = (int)MathF.Floor(source.Top); int bottom = (int)MathF.Ceiling(source.Bottom); return new Rectangle(left, top, right - left, bottom - top); } } }