示例#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);
        }
示例#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 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);
        }
示例#4
0
 public static Vector2f Local2Global(float rotation, float scaleX, float scaleY, float skewX, float skewY, bool flipX, bool flipY, float centerX, float centerY, float posX, float posY, Vector2f resultPoint)
 {
     _trans.Idt();
     if (rotation != 0)
     {
         _trans.Translate(centerX, centerY);
         _trans.PreRotate(rotation);
         _trans.Translate(-centerX, -centerY);
     }
     if (flipX || flipY)
     {
         if (flipX && flipY)
         {
             Affine2f.Transform(_trans, centerX, centerY, Affine2f.TRANS_ROT180);
         }
         else if (flipX)
         {
             Affine2f.Transform(_trans, centerX, centerY, Affine2f.TRANS_MIRROR);
         }
         else if (flipY)
         {
             Affine2f.Transform(_trans, centerX, centerY, Affine2f.TRANS_MIRROR_ROT180);
         }
     }
     if ((scaleX != 1) || (scaleY != 1))
     {
         _trans.Translate(centerX, centerY);
         _trans.PreScale(scaleX, scaleY);
         _trans.Translate(-centerX, -centerY);
     }
     if ((skewX != 0) || (skewY != 0))
     {
         _trans.Translate(centerX, centerY);
         _trans.PreShear(skewX, skewY);
         _trans.Translate(-centerX, -centerY);
     }
     if (resultPoint != null)
     {
         _trans.TransformPoint(posX, posY, resultPoint);
         return(resultPoint);
     }
     return(resultPoint);
 }
示例#5
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);
        }