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 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 SheetPosition(int sheetIndex, Rectangle32 rectangle) { SheetIndex = sheetIndex; Rectangle = rectangle; }