private Rectangle32 Blit( IntPtr source, Rectangle32 sourceRectangle, IntPtr destination, Point32 destinationPosition) { Span <int> rects = stackalloc int[] { sourceRectangle.Position.X, sourceRectangle.Position.Y, sourceRectangle.Size.X, sourceRectangle.Size.Y, destinationPosition.X, destinationPosition.Y, 0, 0 }; var result = _sdl.BlitSurface( source, rects[0], destination, ref rects[4]); if (result < 0) { throw new SdlException("Error on surface blit: " + _sdl.GetError()); } return(new Rectangle32( new Point32(rects[4], rects[5]), new Point32(rects[6], rects[7]))); }
private static void InnerPack( this Rectangle32 r, Point32 size, int rightHeight, int bottomWidth, out Rectangle32 rx, out Rectangle32 ry) { rx = new Rectangle32( new Point32(r.Position.X + size.X, r.Position.Y), new Point32(r.Size.X - size.X, rightHeight)); ry = new Rectangle32( new Point32(r.Position.X, r.Position.Y + size.Y), new Point32(bottomWidth, r.Size.Y - size.Y)); }
public static void Pack( this Rectangle32 r, Point32 size, out Rectangle32 rx, out Rectangle32 ry) { var fit = r.Size - size; if (fit.X < fit.Y) { r.PackSmallX(size, out rx, out ry); } else { r.PackSmallY(size, out rx, out ry); } }
public Rectangle32(Point32 position, Point32 size) { Position = position; Size = size; }
public LineSegment32(Point32 a, Point32 b) { A = a; B = b; }
public static Rectangle32 Moved(this Rectangle32 r, Point32 offset) => new(r.Position + offset, r.Size);
public static void PackSmallY( this Rectangle32 r, Point32 size, out Rectangle32 rx, out Rectangle32 ry) => r.InnerPack(size, r.Size.Y, size.X, out rx, out ry);
public static int Min(this Point32 p) => Math.Min(p.X, p.Y);
public static bool AnyNegative(this Point32 p) => p.X < 0 || p.Y < 0;
public static bool AllPositive(this Point32 p) => 0 < p.X && 0 < p.Y;
public static Point32 Moved(this Point32 p, int dx, int dy) => new(p.X + dx, p.Y + dy);
public static int Max(this Point32 p) => Math.Max(p.X, p.Y);
public Circle32(Point32 center, int radius) { Center = center; Radius = radius; }