Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
WidgetAnchor.cs
1using System.Drawing;
2
3namespace Gondwana.Widgets;
4
37
38internal static class WidgetAnchorExtensions
39{
40 internal static PointF GetPoint(
41 this WidgetAnchor anchor,
42 Rectangle bounds)
43 {
44 float centerX = bounds.Left + bounds.Width / 2f;
45 float centerY = bounds.Top + bounds.Height / 2f;
46
47 return anchor switch
48 {
49 WidgetAnchor.TopLeft => new PointF(bounds.Left, bounds.Top),
50 WidgetAnchor.TopCenter => new PointF(centerX, bounds.Top),
51 WidgetAnchor.TopRight => new PointF(bounds.Right, bounds.Top),
52 WidgetAnchor.CenterLeft => new PointF(bounds.Left, centerY),
53 WidgetAnchor.Center => new PointF(centerX, centerY),
54 WidgetAnchor.CenterRight => new PointF(bounds.Right, centerY),
55 WidgetAnchor.BottomLeft => new PointF(bounds.Left, bounds.Bottom),
56 WidgetAnchor.BottomCenter => new PointF(centerX, bounds.Bottom),
57 WidgetAnchor.BottomRight => new PointF(bounds.Right, bounds.Bottom),
58 _ => throw new ArgumentOutOfRangeException(nameof(anchor), anchor, null)
59 };
60 }
61}
WidgetAnchor
Identifies one of the nine common anchor points on a rectangle.
@ TopRight
The upper-right corner.
@ Center
The center of the rectangle.
@ BottomRight
The lower-right corner.
@ TopCenter
The center of the upper edge.
@ BottomLeft
The lower-left corner.
@ CenterLeft
The center of the left edge.
@ CenterRight
The center of the right edge.
@ TopLeft
The upper-left corner.
@ BottomCenter
The center of the lower edge.