public override void DrawStringBaseline(string fontName, float size, string text, float x, float y, float start_x, Color4 color, bool underline = false, TextShadow shadow = default)
 {
     using (var layout = new TextLayout(dwFactory, text, GetFormat(fontName, ConvertSize(size)), float.MaxValue, float.MaxValue))
     {
         var indent = (x - start_x);
         if (Math.Abs(indent) > 0.001f)
         {
             layout.SetInlineObject(new Indent(indent), new TextRange(0, 0));
         }
         layout.SetDrawingEffect(new ColorDrawingEffect(color, shadow), new TextRange(0, text.Length));
         layout.Draw(Renderer, 0, 0);
         foreach (var q in Renderer.Quads)
         {
             var d = q.Destination;
             d.X += (int)start_x;
             d.Y += (int)y;
             if (q.Texture == null)
             {
                 render2d.FillRectangle(d, q.Color);
             }
             else
             {
                 render2d.Draw(q.Texture, q.Source, d, q.Color);
             }
         }
         Renderer.Quads = new List <DrawQuad>();
     }
 }
예제 #2
0
 void Draw(PGQuad *quads, int count)
 {
     if (drawX == int.MaxValue)
     {
         lastQuads = new PGQuad[count];
         for (int i = 0; i < lastQuads.Length; i++)
         {
             lastQuads[i] = quads[i];
         }
         return;
     }
     for (int i = 0; i < count; i++)
     {
         var q = quads[i];
         q.Dest.X += drawX;
         q.Dest.Y += drawY;
         if (q.Texture == (PGTexture *)0)
         {
             ren.FillRectangle(q.Dest, q.Color);
         }
         else
         {
             var t = textures[(int)q.Texture->UserData];
             ren.Draw(t, q.Source, q.Dest, q.Color);
         }
     }
 }
예제 #3
0
        protected override void OnRender(GameTime gameTime)
        {
            // TODO: word-wrap
            var text = _text;

            var measure = _font.MeasureString(text);

            var rect = new Rectangle(0, App.Window.Height - measure.Y, App.Window.Width, measure.Y);

            _renderer.ProjectionMatrix =
                Matrix4x4.CreateOrthographicOffCenter(0, App.Window.Width, App.Window.Height, 0, -1, 1);

            _renderer.Begin();
            _renderer.FillRectangle(rect, Color.Gray);
            _renderer.DrawString(_font, text, rect.Location, Color.White);
            _renderer.End();
        }
예제 #4
0
        public override void RenderText(BuiltRichText txt, int x, int y)
        {
            var dw = (DirectWriteBuiltText)txt;

            foreach (var q in dw.Quads)
            {
                var d = q.Destination;
                d.X += x;
                d.Y += y;
                if (q.Texture == null)
                {
                    render2d.FillRectangle(d, q.Color);
                }
                else
                {
                    render2d.Draw(q.Texture, q.Source, d, q.Color);
                }
            }
        }
예제 #5
0
 void Draw(PGQuad *quads, PGTexture *texture, int count)
 {
     if (texture == (PGTexture *)0)
     {
         for (int i = 0; i < count; i++)
         {
             var q = quads[i];
             q.Dest.X += drawX;
             q.Dest.Y += drawY;
             ren.FillRectangle(q.Dest, q.Color);
         }
     }
     else
     {
         var t = textures[(int)texture->UserData];
         for (int i = 0; i < count; i++)
         {
             var q = quads[i];
             q.Dest.X += drawX;
             q.Dest.Y += drawY;
             ren.Draw(t, q.Source, q.Dest, q.Color);
         }
     }
 }
예제 #6
0
 public void FillRectangle(Rectangle rect, Color color)
 {
     _spriteBatch.FillRectangle(rect, GetProperTint(color));
 }