public static void DrawSurface(this IDrawing drawing, ISurface surface, int x, int y, int width, int height, Flip flip = Flip.None) { var src = new Rectangle(0, 0, surface.Width, surface.Height); var dst = new Rectangle(x, y, width, height); drawing.DrawSurface(surface, src, dst, flip); }
public static void DrawAnimation(this IDrawing drawing, FramesGroup framesGroup, double x, double y, float alpha = 1.0f, Drawing.Flip flip = Drawing.Flip.None) { var frame = framesGroup.Frames.FirstOrDefault(); if (frame != null) { var src = frame.Source; flip = flip.Add(Drawing.Flip.FlipHorizontal, framesGroup.Reference.FlipX) .Add(Drawing.Flip.FlipVertical, framesGroup.Reference.FlipY); var nx = x - frame.Pivot.X; var ny = y - frame.Pivot.Y; if (flip.HasFlag(Drawing.Flip.FlipHorizontal)) { nx += frame.Pivot.X * 2 - src.Width; } if (flip.HasFlag(Drawing.Flip.FlipVertical)) { ny -= frame.Pivot.Y * 2 - src.Height; } drawing.DrawSurface(framesGroup.Texture, new System.Drawing.Rectangle((int)src.Left, (int)src.Top, (int)src.Width, (int)src.Height), new System.Drawing.Rectangle((int)nx, (int)ny, (int)src.Width, (int)src.Height), alpha, flip); } }
protected void DrawImage(ISurface surface, double x, double y, int sourceX, int sourceY, int width, int height, double scaleX, double scaleY, ColorF color) { var dstWidth = width * scaleX; var dstHeight = height * scaleY; var src = new Rectangle(sourceX, sourceY, width, height); var dst = new Rectangle((int)x, (int)y, (int)dstWidth, (int)dstHeight); _drawing.DrawSurface(surface, src, dst, color); }
private void DrawFrame(Context context, Sequence.Frame frame) { drawing.DrawSurface(surface, Rectangle.FromLTRB(frame.Left, frame.Top, frame.Right, frame.Bottom), RectangleF.FromLTRB(context.PositionX + context.Left, context.PositionY + context.Top, context.PositionX + context.Right, context.PositionY + context.Bottom), Multiply(ConvertColor(frame.ColorLeft), context.Color), Multiply(ConvertColor(frame.ColorTop), context.Color), Multiply(ConvertColor(frame.ColorRight), context.Color), Multiply(ConvertColor(frame.ColorBottom), context.Color)); }
public static void DrawSurface(this IDrawing drawing, ISurface surface, Rectangle src, RectangleF dst, ColorF color) => drawing.DrawSurface(surface, src, dst, color, color, color, color);
public static void DrawSurface(this IDrawing drawing, ISurface surface, Rectangle src, Rectangle dst, Flip flip = Flip.None) => drawing.DrawSurface(surface, src, new RectangleF(dst.X, dst.Y, dst.Width, dst.Height), flip);
public static void DrawSurface(this IDrawing drawing, ISurface surface, Rectangle src, int x, int y, int width, int height, Flip flip = Flip.None) => drawing.DrawSurface(surface, src, new Rectangle(x, y, width, height), flip);
public static void DrawSurface(this IDrawing drawing, ISurface surface, Rectangle dst, Flip flip = Flip.None) => drawing.DrawSurface(surface, new Rectangle(0, 0, surface.Width, surface.Height), dst, flip);