Ejemplo n.º 1
0
        public static Affine2f Transform(Affine2f tx, float x, float y, int transform, float width, float height)
        {
            switch (transform)
            {
            case TRANS_ROT90:
            {
                float w = x + width / 2;
                float h = y + height / 2;
                tx.Translate(w, h);
                tx.Rotate(ANGLE_90);
                tx.Translate(-w, -h);
                break;
            }

            case TRANS_ROT180:
            {
                float w = x + width / 2;
                float h = y + height / 2;
                tx.Translate(w, h);
                tx.Rotate(MathUtils.PI);
                tx.Translate(-w, -h);
                break;
            }

            case TRANS_ROT270:
            {
                float w = x + width / 2;
                float h = y + height / 2;
                tx.Translate(w, h);
                tx.Rotate(ANGLE_270);
                tx.Translate(-w, -h);
                break;
            }

            case TRANS_MIRROR:
            {
                float w = x + width / 2;
                float h = y + height / 2;
                tx.Translate(w, h);
                tx.Scale(-1, 1);
                tx.Translate(-w, -h);
                break;
            }

            case TRANS_MIRROR_ROT90:
            {
                float w = x + width / 2;
                float h = y + height / 2;
                tx.Translate(w, h);
                tx.Rotate(ANGLE_90);
                tx.Translate(-w, -h);
                tx.Scale(-1, 1);
                break;
            }

            case TRANS_MIRROR_ROT180:
            {
                float w = x + width / 2;
                float h = y + height / 2;
                tx.Translate(w, h);
                tx.Scale(-1, 1);
                tx.Translate(-w, -h);
                w = x + width / 2;
                h = y + height / 2;
                tx.Translate(w, h);
                tx.Rotate(MathUtils.PI);
                tx.Translate(-w, -h);
                break;
            }

            case TRANS_MIRROR_ROT270:
            {
                float w = x + width / 2;
                float h = y + height / 2;
                tx.Translate(w, h);
                tx.Rotate(ANGLE_270);
                tx.Translate(-w, -h);
                tx.Scale(-1, 1);
                break;
            }
            }
            return(tx);
        }
Ejemplo n.º 2
0
        public static Affine2f transform(Affine2f tx, float x, float y, int transform)
        {
            switch (transform)
            {
            case TRANS_ROT90:
            {
                tx.Translate(x, y);
                tx.Rotate(ANGLE_90);
                tx.Translate(-x, -y);
                break;
            }

            case TRANS_ROT180:
            {
                tx.Translate(x, y);
                tx.Rotate(MathUtils.PI);
                tx.Translate(-x, -y);
                break;
            }

            case TRANS_ROT270:
            {
                tx.Translate(x, y);
                tx.Rotate(ANGLE_270);
                tx.Translate(-x, -y);
                break;
            }

            case TRANS_MIRROR:
            {
                tx.Translate(x, y);
                tx.Scale(-1, 1);
                tx.Translate(-x, -y);
                break;
            }

            case TRANS_MIRROR_ROT90:
            {
                tx.Translate(x, y);
                tx.Rotate(ANGLE_90);
                tx.Translate(-x, -y);
                tx.Scale(-1, 1);
                break;
            }

            case TRANS_MIRROR_ROT180:
            {
                tx.Translate(x, y);
                tx.Scale(-1, 1);
                tx.Translate(-x, -y);
                tx.Translate(x, y);
                tx.Rotate(MathUtils.PI);
                tx.Translate(-x, -y);
                break;
            }

            case TRANS_MIRROR_ROT270:
            {
                tx.Translate(x, y);
                tx.Rotate(ANGLE_270);
                tx.Translate(-x, -y);
                tx.Scale(-1, 1);
                break;
            }
            }
            return(tx);
        }