Example #1
0
 public virtual GLEx Draw(Painter texture, float x, float y, float w, float h, LColor color, float rotation, float sx, float sy, bool flipX, bool flipY)
 {
     return(Draw(texture, x, y, w, h, color, rotation, null, sx, sy, flipX, flipY));
 }
Example #2
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);
        }
Example #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)
 {
     return(Draw(texture, x, y, w, h, color, rotation, pivot, sx, sy, false, false));
 }
Example #4
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, Direction dir)
 {
     return(Draw(texture, x, y, Width, Height, srcX, srcY, srcWidth, srcHeight, color, rotation, scaleX, scaleY, origin, null, dir));
 }