Exemple #1
0
        public void PushVertex(Vector2 vertex, Color color)
        {
            PrimitiveBatchNeeded();

            if (_texture != null)
            {
                _primitiveBatch.AddVertex(vertex, color, Vector2.Zero);
            }
            else
            {
                _primitiveBatch.AddVertex(vertex, color);
            }
        }
Exemple #2
0
        void DrawGlyph(PrimitiveBatch primitiveBatch, Glyph glyph, ref Vector2 position, ref Color color, float scale, ref Vector2 right, ref Vector2 down)
        {
            float topLeftX = (glyph.X - 1) / (float)FontSheet.Width;
            float topLeftY = (glyph.Y - 1) / (float)FontSheet.Height;

            float bottomRightX = (float)(glyph.X + glyph.Width + 1) / (float)FontSheet.Width;
            float bottomRightY = (float)(glyph.Y + glyph.Height + 1) / (float)FontSheet.Height;

            Vector2 topLeft  = position - (right + down) * scale;
            Vector2 topRight = position + (right - down) * scale + right * glyph.Width * scale;

            Vector2 bottomLeft  = position - (right - down) * scale + down * glyph.Height * scale;
            Vector2 bottomRight = position + (right + down) * scale + right * glyph.Width * scale + down * glyph.Height * scale;

            primitiveBatch.AddVertex(topLeft.X, topLeft.Y, ref color, topLeftX, topLeftY);
            primitiveBatch.AddVertex(bottomLeft.X, bottomLeft.Y, ref color, topLeftX, bottomRightY);
            primitiveBatch.AddVertex(topRight.X, topRight.Y, ref color, bottomRightX, topLeftY);

            primitiveBatch.AddVertex(bottomLeft.X, bottomLeft.Y, ref color, topLeftX, bottomRightY);
            primitiveBatch.AddVertex(topRight.X, topRight.Y, ref color, bottomRightX, topLeftY);
            primitiveBatch.AddVertex(bottomRight.X, bottomRight.Y, ref color, bottomRightX, bottomRightY);
        }