Beispiel #1
0
 public static SpriteDrawingContext TextureWrapHorizontal(this SpriteDrawingContext context, TextureWrapMode mode, float left, float right)
 {
     context.TextureWrapU       = mode;
     context.TextureRegionLeft  = left;
     context.TextureRegionRight = right;
     return(context);
 }
Beispiel #2
0
 public static SpriteDrawingContext TextureWrapVertical(this SpriteDrawingContext context, TextureWrapMode mode, float top, float bottom)
 {
     context.TextureWrapV        = mode;
     context.TextureRegionTop    = top;
     context.TextureRegionBottom = bottom;
     return(context);
 }
Beispiel #3
0
 public static SpriteDrawingContext DestinationSize(this SpriteDrawingContext context, float width, float height)
 {
     context.Vec1 = new Vector2(context.Vec0.X + width, context.Vec0.Y);
     context.Vec2 = new Vector2(context.Vec0.X, context.Vec0.Y + height);
     context.Vec3 = new Vector2(context.Vec0.X + width, context.Vec0.Y + height);
     return(context);
 }
Beispiel #4
0
 public static SpriteDrawingContext ColorMultiply(this SpriteDrawingContext context, ColorF color)
 {
     context.Color0 *= color;
     context.Color1 *= color;
     context.Color2 *= color;
     context.Color3 *= color;
     return(context);
 }
Beispiel #5
0
 public static SpriteDrawingContext ColorAdd(this SpriteDrawingContext context, ColorF color)
 {
     context.Color0 += color;
     context.Color1 += color;
     context.Color2 += color;
     context.Color3 += color;
     return(context);
 }
Beispiel #6
0
 public static SpriteDrawingContext Color(this SpriteDrawingContext context, ColorF color)
 {
     context.Color0 = color;
     context.Color1 = color;
     context.Color2 = color;
     context.Color3 = color;
     return(context);
 }
Beispiel #7
0
 public static SpriteDrawingContext ColorDefault(this SpriteDrawingContext context)
 {
     context.Color0 = ColorWhite;
     context.Color1 = ColorWhite;
     context.Color2 = ColorWhite;
     context.Color3 = ColorWhite;
     return(context);
 }
Beispiel #8
0
 public static SpriteDrawingContext Source(this SpriteDrawingContext context, float x, float y, float width, float height)
 {
     context.SourceLeft   = x;
     context.SourceTop    = y;
     context.SourceRight  = x + width;
     context.SourceBottom = y + height;
     return(context);
 }
Beispiel #9
0
 public static SpriteDrawingContext SourceLTRB(this SpriteDrawingContext context, float left, float top, float right, float bottom)
 {
     context.SourceLeft   = left;
     context.SourceTop    = top;
     context.SourceRight  = right;
     context.SourceBottom = bottom;
     return(context);
 }
Beispiel #10
0
        public static SpriteDrawingContext RotateZ(this SpriteDrawingContext context, float rotation)
        {
            var matrix = Matrix4x4.CreateRotationZ(rotation);

            context.Vec0 = Vector2.Transform(context.Vec0, matrix);
            context.Vec1 = Vector2.Transform(context.Vec1, matrix);
            context.Vec2 = Vector2.Transform(context.Vec2, matrix);
            context.Vec3 = Vector2.Transform(context.Vec3, matrix);
            return(context);
        }
Beispiel #11
0
        public static SpriteDrawingContext ScaleSize(this SpriteDrawingContext context, float scaleX, float scaleY)
        {
            var matrix = Matrix4x4.CreateScale(scaleX, scaleY, 1.0f);

            context.Vec0 = Vector2.Transform(context.Vec0, matrix);
            context.Vec1 = Vector2.Transform(context.Vec1, matrix);
            context.Vec2 = Vector2.Transform(context.Vec2, matrix);
            context.Vec3 = Vector2.Transform(context.Vec3, matrix);
            return(context);
        }
Beispiel #12
0
        public static SpriteDrawingContext Traslate(this SpriteDrawingContext context, float x, float y)
        {
            var v = new Vector2(x, y);

            context.Vec0 += v;
            context.Vec1 += v;
            context.Vec2 += v;
            context.Vec3 += v;
            return(context);
        }
Beispiel #13
0
        public static SpriteDrawingContext Position(this SpriteDrawingContext context, float x, float y)
        {
            var width  = context.Vec3.X - context.Vec0.X;
            var height = context.Vec3.Y - context.Vec0.Y;

            context.Vec0 = new Vector2(x, y);
            context.Vec1 = new Vector2(x + width, y);
            context.Vec2 = new Vector2(x, y + height);
            context.Vec3 = new Vector2(x + width, y + height);
            return(context);
        }
Beispiel #14
0
 public static SpriteDrawingContext SpriteTexture(this SpriteDrawingContext context, ISpriteTexture spriteTexture)
 {
     context.SpriteTexture = spriteTexture;
     return(context);
 }
Beispiel #15
0
 public static SpriteDrawingContext MatchSourceSize(this SpriteDrawingContext context) =>
 context.DestinationSize(
     Math.Abs(context.SourceRight - context.SourceLeft),
     Math.Abs(context.SourceBottom - context.SourceTop));