Exemple #1
0
        public virtual GLEx Draw(Painter texture, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh, float rotation)
        {
            if (isClosed)
            {
                return(this);
            }
            if (texture == null)
            {
                return(this);
            }
            if (rotation == 0)
            {
                texture.AddToBatch(batch, this.lastBrush.baseColor, Tx, dx, dy, dw, dh, sx, sy, sw, sh);
                return(this);
            }
            Affine2f xf = Tx;

            if (rotation != 0)
            {
                xf = new Affine2f();
                float w1 = dx + dw / 2;
                float h1 = dy + dh / 2;
                xf.Translate(w1, h1);
                xf.PreRotate(rotation);
                xf.Translate(-w1, -h1);
                Affine2f.Multiply(Tx, xf, xf);
            }
            texture.AddToBatch(batch, this.lastBrush.baseColor, xf, dx, dy, dw, dh, sx, sy, sw, sh);
            return(this);
        }
Exemple #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);
        }
Exemple #3
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);
        }
Exemple #4
0
 public virtual GLEx Draw(Painter texture, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh)
 {
     if (isClosed)
     {
         return(this);
     }
     if (texture == null)
     {
         return(this);
     }
     texture.AddToBatch(batch, this.lastBrush.baseColor, Tx, dx, dy, dw, dh, sx, sy, sw, sh);
     return(this);
 }
Exemple #5
0
 public virtual GLEx Draw(Painter texture, float x, float y, float w, float h)
 {
     if (isClosed)
     {
         return(this);
     }
     if (texture == null)
     {
         return(this);
     }
     texture.AddToBatch(batch, this.lastBrush.baseColor, Tx, x, y, w, h);
     return(this);
 }
Exemple #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);
        }
Exemple #7
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);
        }
Exemple #8
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);
        }