Exemplo n.º 1
0
        public virtual void DrawImage(int x, int y, int w, int h, IImage image, float us, float vs, float ue, float ve, ThW.UI.Utils.Color color, bool outLineOnly)
        {
            float d = -0.5f;

            XNAVertex[] v = new XNAVertex[4];
            v[0].Position.X          = (float)x + d;
            v[0].Position.Y          = (float)y + d;
            v[0].Position.Z          = 0.0f;
            v[0].TextureCoordinate.X = us;
            v[0].TextureCoordinate.Y = vs;
            v[0].Color.R             = (byte)(255 * color.R);
            v[0].Color.G             = (byte)(255 * color.G);
            v[0].Color.B             = (byte)(255 * color.B);
            v[0].Color.A             = (byte)(255 * color.A);

            v[1].Position.X          = (float)x + (float)w + d;
            v[1].Position.Y          = (float)y + d;
            v[1].Position.Z          = 0.0f;
            v[1].TextureCoordinate.X = ue;
            v[1].TextureCoordinate.Y = vs;
            v[1].Color.R             = (byte)(255 * color.R);
            v[1].Color.G             = (byte)(255 * color.G);
            v[1].Color.B             = (byte)(255 * color.B);
            v[1].Color.A             = (byte)(255 * color.A);

            v[2].Position.X          = (float)x + d;
            v[2].Position.Y          = (float)y + (float)h + d;
            v[2].Position.Z          = 0.0f;
            v[2].TextureCoordinate.X = us;
            v[2].TextureCoordinate.Y = ve;
            v[2].Color.R             = (byte)(255 * color.R);
            v[2].Color.G             = (byte)(255 * color.G);
            v[2].Color.B             = (byte)(255 * color.B);
            v[2].Color.A             = (byte)(255 * color.A);

            v[3].Position.X          = (float)x + (float)w + d;
            v[3].Position.Y          = (float)y + (float)h + d;
            v[3].Position.Z          = 0.0f;
            v[3].TextureCoordinate.X = ue;
            v[3].TextureCoordinate.Y = ve;
            v[3].Color.R             = (byte)(255 * color.R);
            v[3].Color.G             = (byte)(255 * color.G);
            v[3].Color.B             = (byte)(255 * color.B);
            v[3].Color.A             = (byte)(255 * color.A);

            short[] indx = { 0, 1, 3, 3, 2, 0 };

            this.effect2d.Texture = ((XNAImage)image).Texture;

            foreach (EffectPass pass in this.effect2d.CurrentTechnique.Passes)
            {
                pass.Apply();

                device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, v, 0, 4, indx, 0, 2, this.vertexShaderDeclaration);
            }
        }
Exemplo n.º 2
0
        public virtual void DrawImage(int x, int y, int w, int h, IImage image, float us, float vs, float ue, float ve, ThW.UI.Utils.Color color, bool outLineOnly)
        {
            float d = -0.5f;

            XNAVertex[] v = new XNAVertex[4];
            v[0].Position.X = (float)x + d;
            v[0].Position.Y = (float)y + d;
            v[0].Position.Z = 0.0f;
            v[0].TextureCoordinate.X = us;
            v[0].TextureCoordinate.Y = vs;
            v[0].Color.R = (byte)(255 * color.R);
            v[0].Color.G = (byte)(255 * color.G);
            v[0].Color.B = (byte)(255 * color.B);
            v[0].Color.A = (byte)(255 * color.A);

            v[1].Position.X = (float)x + (float)w + d;
            v[1].Position.Y = (float)y + d;
            v[1].Position.Z = 0.0f;
            v[1].TextureCoordinate.X = ue;
            v[1].TextureCoordinate.Y = vs;
            v[1].Color.R = (byte)(255 * color.R);
            v[1].Color.G = (byte)(255 * color.G);
            v[1].Color.B = (byte)(255 * color.B);
            v[1].Color.A = (byte)(255 * color.A);

            v[2].Position.X = (float)x + d;
            v[2].Position.Y = (float)y + (float)h + d;
            v[2].Position.Z = 0.0f;
            v[2].TextureCoordinate.X = us;
            v[2].TextureCoordinate.Y = ve;
            v[2].Color.R = (byte)(255 * color.R);
            v[2].Color.G = (byte)(255 * color.G);
            v[2].Color.B = (byte)(255 * color.B);
            v[2].Color.A = (byte)(255 * color.A);

            v[3].Position.X = (float)x + (float)w + d;
            v[3].Position.Y = (float)y + (float)h + d;
            v[3].Position.Z = 0.0f;
            v[3].TextureCoordinate.X = ue;
            v[3].TextureCoordinate.Y = ve;
            v[3].Color.R = (byte)(255 * color.R);
            v[3].Color.G = (byte)(255 * color.G);
            v[3].Color.B = (byte)(255 * color.B);
            v[3].Color.A = (byte)(255 * color.A);

            short[] indx = { 0, 1, 3, 3, 2, 0 };

            this.effect2d.Texture = ((XNAImage)image).Texture;

            foreach (EffectPass pass in this.effect2d.CurrentTechnique.Passes)
            {
                pass.Apply();

                device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, v, 0, 4, indx, 0, 2, this.vertexShaderDeclaration);
            }
        }