示例#1
0
        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])));
        }
示例#2
0
 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));
 }
示例#3
0
        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);
            }
        }
示例#4
0
 public Rectangle32(Point32 position, Point32 size)
 {
     Position = position;
     Size     = size;
 }
示例#5
0
 public LineSegment32(Point32 a, Point32 b)
 {
     A = a;
     B = b;
 }
示例#6
0
 public static Rectangle32 Moved(this Rectangle32 r, Point32 offset) => new(r.Position + offset, r.Size);
示例#7
0
 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);
示例#8
0
 public static int Min(this Point32 p) => Math.Min(p.X, p.Y);
示例#9
0
 public static bool AnyNegative(this Point32 p) => p.X < 0 || p.Y < 0;
示例#10
0
 public static bool AllPositive(this Point32 p) => 0 < p.X && 0 < p.Y;
示例#11
0
 public static Point32 Moved(this Point32 p, int dx, int dy) => new(p.X + dx, p.Y + dy);
示例#12
0
 public static int Max(this Point32 p) => Math.Max(p.X, p.Y);
示例#13
0
 public Circle32(Point32 center, int radius)
 {
     Center = center;
     Radius = radius;
 }