Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 public virtual GLEx RestoreTx()
 {
     if (isClosed)
     {
         return(this);
     }
     lastTrans = affineStack.PreviousPop();
     return(this);
 }
Exemplo n.º 5
0
 public virtual GLEx RestoreTx(int idx)
 {
     if (isClosed)
     {
         return(this);
     }
     lastTrans = affineStack.Get(idx);
     return(this);
 }
Exemplo n.º 6
0
 public virtual GLEx RestoreTxDef()
 {
     if (isClosed)
     {
         return(this);
     }
     lastTrans = new Affine2f();
     Scale(scaleX, scaleY);
     affineStack.Pop();
     return(this);
 }
Exemplo n.º 7
0
 public virtual GLEx SaveTx()
 {
     if (isClosed)
     {
         return(this);
     }
     if (lastTrans != null)
     {
         affineStack.Add(lastTrans = lastTrans.Cpy());
     }
     return(this);
 }
Exemplo n.º 8
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);
 }
Exemplo n.º 9
0
        public virtual void AddQuad(LTexture tex, int tint, Affine2f xf, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh)
        {
            if (tex == null || tex.IsClosed())
            {
                return;
            }
            if (dw < 1f || dh < 1f || sw < 1f || sh < 1f)
            {
                return;
            }
            if (LColor.GetAlpha(tint) <= 0)
            {
                return;
            }

            /*
             * Texture = tex;
             * if (tex.Parent == null)
             * {
             *      float displayWidth = tex.width();
             *      float displayHeight = tex.height();
             *      float xOff = ((sx / displayWidth) * tex.widthRatio()) + tex.xOff();
             *      float yOff = ((sy / displayHeight) * tex.heightRatio()) + tex.yOff();
             *      float widthRatio = ((sw / displayWidth) * tex.widthRatio()) + xOff;
             *      float heightRatio = ((sh / displayHeight) * tex.heightRatio()) + yOff;
             *      AddQuad(tint, xf, dx, dy, dx + dw, dy + dh, xOff, yOff, widthRatio, heightRatio);
             * }
             * else
             * {
             *      LTexture forefather = LTexture.firstFather(tex);
             *      float displayWidth = forefather.width();
             *      float displayHeight = forefather.height();
             *      float xOff = ((sx / displayWidth) * forefather.widthRatio()) + forefather.xOff() + tex.xOff();
             *      float yOff = ((sy / displayHeight) * forefather.heightRatio()) + forefather.yOff() + tex.yOff();
             *      float widthRatio = ((sw / displayWidth) * forefather.widthRatio()) + xOff;
             *      float heightRatio = ((sh / displayHeight) * forefather.heightRatio()) + yOff;
             *      AddQuad(tint, xf, dx, dy, dx + dw, dy + dh, xOff, yOff, widthRatio, heightRatio);
             * }*/
        }
Exemplo n.º 10
0
        public virtual void AddQuad(LTexture tex, int tint, Affine2f xf, float x, float y, float w, float h)
        {
            if (tex == null || tex.IsClosed())
            {
                return;
            }
            if (w < 1f || h < 1f)
            {
                return;
            }
            if (LColor.GetAlpha(tint) <= 0)
            {
                return;
            }

            /*
             * Texture = tex;
             *
             * if (tex.Parent == null)
             * {
             *      float u2 = tex.getFormat().repeatX ? w / tex.width() : tex.widthRatio();
             *      float uv = tex.getFormat().repeatY ? h / tex.height() : tex.heightRatio();
             *      AddQuad(tint, xf, x, y, x + w, y + h, tex.xOff(), tex.yOff(), u2, uv);
             * }
             * else
             * {
             *      LTexture forefather = LTexture.firstFather(tex);
             *      float u2 = tex.getFormat().repeatX ? w / forefather.width() : tex.widthRatio();
             *      float uv = tex.getFormat().repeatY ? h / forefather.height() : tex.heightRatio();
             *      if ((w < forefather.width() || h < forefather.height()) && !tex.Scale)
             *      {
             *              AddQuad(tint, xf, x, y, x + w, y + h, tex.xOff(), tex.yOff(), u2, uv);
             *      }
             *      else
             *      {
             *              AddQuad(tint, xf, x, y, x + w, y + h, tex.xOff(), tex.yOff(), forefather.widthRatio(), forefather.heightRatio());
             *      }
             * }*/
        }
Exemplo n.º 11
0
 public GLEx(Graphics gfx, RenderTarget target, BaseBatch def, bool alltex, bool saveFrameBuffer)
 {
     this.gfx    = gfx;
     this.target = target;
     this.batch  = def;
     this.affineStack.Add(lastTrans = new Affine2f());
     this.colorTex = gfx.FinalColorTex();
     if (target != null)
     {
         this.Scale(scaleX = target.Xscale(), scaleY = target.Yscale());
     }
     else
     {
         this.Scale(scaleX = LSystem.GetScaleWidth(), scaleY = LSystem.GetScaleHeight());
     }
     this.lastBrush             = new BrushSave();
     this.lastBrush.font        = LSystem.GetSystemGameFont();
     this.lastBrush.alltextures = alltex;
     this.lastBrush.pixSkip     = LSystem.IsHTML5() ? def_skip_html5 : def_skip;
     this.lastBrush.blend       = BlendMethod.MODE_NORMAL;
     this.brushStack.Add(lastBrush);
     this.saveToFrameBufferTexture = saveFrameBuffer;
     this.Update();
 }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
 public abstract void AddToBatch(BaseBatch batch, uint tint, Affine2f tx, float x, float y, float width, float height);
Exemplo n.º 14
0
 public abstract void AddToBatch(BaseBatch batch, uint tint, Affine2f tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh);
Exemplo n.º 15
0
 public override void AddToBatch(BaseBatch batch, uint tint, Affine2f tx, float x, float y, float width, float height)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 16
0
 public override void AddToBatch(BaseBatch batch, uint tint, Affine2f tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 17
0
 public virtual void AddQuad(int tint, Affine2f xf, float left, float top, float right, float bottom, float sl, float st, float sr, float sb)
 {
     AddQuad(tint, xf.m00, xf.m01, xf.m10, xf.m11, xf.tx, xf.ty, left, top, right, bottom, sl, st, sr, sb);
 }