예제 #1
0
        public virtual GLEx Draw(Painter texture, float x, float y, float w, float h, LColor color, float rotation, Vector2f pivot, float sx, float sy, bool flipX, bool flipY)
        {
            if (isClosed)
            {
                return(this);
            }
            if (texture == null)
            {
                return(this);
            }
            uint argb = this.lastBrush.baseColor;

            if (color != null)
            {
                argb = (uint)color.GetARGB(Alpha());
            }
            Affine2f xf = Tx;

            if (rotation != 0 || sx != 1f || sy != 1f || flipX || flipY)
            {
                xf = new Affine2f();
                float centerX = x + w / 2;
                float centerY = y + h / 2;
                if (pivot != null && (pivot.x != -1 && pivot.y != -1))
                {
                    centerX = x + pivot.x;
                    centerX = y + pivot.y;
                }
                if (rotation != 0)
                {
                    xf.Translate(centerX, centerY);
                    xf.PreRotate(rotation);
                    xf.Translate(-centerX, -centerY);
                }
                if (flipX || flipY)
                {
                    if (flipX && flipY)
                    {
                        Affine2f.Transform(xf, x, y, Affine2f.TRANS_ROT180, w, h);
                    }
                    else if (flipX)
                    {
                        Affine2f.Transform(xf, x, y, Affine2f.TRANS_MIRROR, w, h);
                    }
                    else if (flipY)
                    {
                        Affine2f.Transform(xf, x, y, Affine2f.TRANS_MIRROR_ROT180, w, h);
                    }
                }
                if (sx != 1f || sy != 1f)
                {
                    xf.Translate(centerX, centerY);
                    xf.PreScale(sx, sy);
                    xf.Translate(-centerX, -centerY);
                }
                Affine2f.Multiply(Tx, xf, xf);
            }
            texture.AddToBatch(batch, argb, xf, x, y, w, h);
            return(this);
        }
예제 #2
0
        public virtual GLEx Draw(Painter texture, float x, float y, float w, float h, LColor color, float rotation)
        {
            if (isClosed)
            {
                return(this);
            }
            if (texture == null)
            {
                return(this);
            }
            uint argb = this.lastBrush.baseColor;

            if (color != null)
            {
                argb = (uint)color.GetARGB(Alpha());
            }
            Affine2f xf = Tx;

            if (rotation != 0)
            {
                xf = new Affine2f();
                float w1 = x + w / 2;
                float h1 = y + h / 2;
                xf.Translate(w1, h1);
                xf.PreRotate(rotation);
                xf.Translate(-w1, -h1);
                Affine2f.Multiply(Tx, xf, xf);
            }
            texture.AddToBatch(batch, argb, xf, x, y, w, h);
            return(this);
        }
예제 #3
0
        public virtual GLEx SetColor(LColor color)
        {
            if (color == null)
            {
                return(this);
            }
            int argb = color.GetARGB();

            SetColor(argb);
            return(this);
        }
예제 #4
0
        public virtual GLEx Draw(Painter texture, float x, float y, float w, float h, LColor color)
        {
            if (isClosed)
            {
                return(this);
            }
            if (texture == null)
            {
                return(this);
            }
            uint argb = this.lastBrush.baseColor;

            if (color != null)
            {
                argb = (uint)color.GetARGB(Alpha());
            }
            texture.AddToBatch(batch, argb, Tx, x, y, w, h);
            return(this);
        }
예제 #5
0
파일: Game1.cs 프로젝트: shiguang1120/LGame
        public Game1()
        {
            _graphics             = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IsMouseVisible        = true;

            //1123418112

            JavaSystem.Out.Println(NumberUtils.FloatToIntBits(123f));


            //2079648233
            JavaSystem.Out.Println(LColor.GetARGB(244, 233, 233, 123));
            //ff000000
            JavaSystem.Out.Println(new LColor(LColor.TRANSPARENT));
            //7bf4e9e9
            JavaSystem.Out.Println(new LColor(244, 233, 233, 123));
            //1,2,3,4
            JavaSystem.Out.Println(new LColor(1, 2, 3, 4).GetXNAColor());
        }
예제 #6
0
        public virtual GLEx Draw(Painter texture, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh, LColor color)
        {
            if (isClosed)
            {
                return(this);
            }
            if (texture == null)
            {
                return(this);
            }
            if (LColor.white.Equals(color))
            {
                texture.AddToBatch(batch, this.lastBrush.baseColor, Tx, dx, dy, dw, dh, sx, sy, sw, sh);
                return(this);
            }
            uint argb = this.lastBrush.baseColor;

            if (color != null)
            {
                argb = (uint)color.GetARGB(Alpha());
            }
            texture.AddToBatch(batch, argb, Tx, dx, dy, dw, dh, sx, sy, sw, sh);
            return(this);
        }
예제 #7
0
 public virtual GLEx SetTint(LColor color)
 {
     return(this.SetTint(color.GetARGB()));
 }
예제 #8
0
 public virtual GLEx SetTint(float r, float g, float b, float a)
 {
     return(SetColor(LColor.GetARGB((int)(r > 1 ? r : r * 255), (int)(g > 1 ? g : r * 255), (int)(b > 1 ? b : b * 255), (int)(a > 1 ? a : a * 255))));
 }
예제 #9
0
 public virtual GLEx SetTint(int r, int g, int b, int a)
 {
     return(SetColor(LColor.GetARGB(r, g, b, a)));
 }
예제 #10
0
        public virtual GLEx Draw(Painter texture, float x, float y, float Width, float Height, float srcX, float srcY, float srcWidth, float srcHeight, LColor color, float rotation, float scaleX, float scaleY, Vector2f origin, Vector2f pivot, Direction dir)
        {
            if (isClosed)
            {
                return(this);
            }
            if (texture == null)
            {
                return(this);
            }

            Affine2f xf = Tx;

            bool dirDirty = (dir != default && dir != Direction.TRANS_NONE);

            bool rotDirty = (rotation != 0 || pivot != null);

            bool oriDirty = (origin != null && (origin.x != 0 || origin.y != 0));

            bool scaleDirty = !(scaleX == 1 && scaleY == 1);

            if (dirDirty || rotDirty || oriDirty || scaleDirty)
            {
                xf = new Affine2f();
                if (oriDirty)
                {
                    xf.Translate(origin.x, origin.y);
                }
                if (rotDirty)
                {
                    float centerX = x + Width / 2;
                    float centerY = y + Height / 2;
                    if (pivot != null && (pivot.x != -1 && pivot.y != -1))
                    {
                        centerX = x + pivot.x;
                        centerX = y + pivot.y;
                    }
                    xf.Translate(centerX, centerY);
                    xf.PreRotate(rotation);
                    xf.Translate(-centerX, -centerY);
                }
                if (scaleDirty)
                {
                    float centerX = x + Width / 2;
                    float centerY = y + Height / 2;
                    if (pivot != null && (pivot.x != -1 && pivot.y != -1))
                    {
                        centerX = x + pivot.x;
                        centerX = y + pivot.y;
                    }
                    xf.Translate(centerX, centerY);
                    xf.PreScale(scaleX, scaleY);
                    xf.Translate(-centerX, -centerY);
                }
                if (dirDirty)
                {
                    switch (dir)
                    {
                    case loon.opengl.GLEx.Direction.TRANS_MIRROR:
                        Affine2f.Transform(xf, x, y, Affine2f.TRANS_MIRROR, Width, Height);
                        break;

                    case loon.opengl.GLEx.Direction.TRANS_FLIP:
                        Affine2f.Transform(xf, x, y, Affine2f.TRANS_MIRROR_ROT180, Width, Height);
                        break;

                    case loon.opengl.GLEx.Direction.TRANS_MF:
                        Affine2f.Transform(xf, x, y, Affine2f.TRANS_ROT180, Width, Height);
                        break;

                    default:
                        break;
                    }
                }
                Affine2f.Multiply(Tx, xf, xf);
            }

            uint argb = this.lastBrush.baseColor;

            if (color != null)
            {
                argb = (uint)color.GetARGB(Alpha());
            }
            texture.AddToBatch(batch, argb, xf, x, y, Width, Height, srcX, srcY, srcWidth, srcHeight);
            return(this);
        }