Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 - Fill Region

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    NT8 - Fill Region

    Hello,

    What is the best way in NT8 onRender to fill a region with 4 data points between 2 lines?

    Thank you

    #2
    Hello mk77ch,

    This would depend on the type of shape you are wanting.

    The easist way would be to use RenderTarget.FillRectangle().


    If you need a non-rectangular shape, you may want to use RenderTarget.FillGeometry().

    Below is a link to a 3rd party site that shows an example of this.
    I have 4 float points (positions in 2D) and I want to draw and fill a polygon (with vertices at those 4 positions) in 2D. How can I do that with sharpdx?
    Last edited by NinjaTrader_ChelseaB; 10-24-2016, 03:04 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thank you very much for your reply.
      I would need the FillGeometry example.
      Did you post the correct link for the 3rd party site?
      The link points to the Ninjatrader Help files.

      Best regards,
      Mike

      Comment


        #4
        Hi Mike,

        My clipboard is acting up today.

        The correct link is below.
        I have 4 float points (positions in 2D) and I want to draw and fill a polygon (with vertices at those 4 positions) in 2D. How can I do that with sharpdx?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you Chelsea,

          in case somebody needs a working example to use in onRender, here is a snippet.
          My sample fills a trapezoid between two lines (4 data points):

          Code:
          SharpDX.Direct2D1.PathGeometry geo = new SharpDX.Direct2D1.PathGeometry(RenderTarget.Factory);
          SharpDX.Direct2D1.GeometrySink snk;
          
          SharpDX.Vector2[] vec = new SharpDX.Vector2[4];
          
          vec[0] = new SharpDX.Vector2(x1, y1);
          vec[1] = new SharpDX.Vector2(x2, y3);
          vec[2] = new SharpDX.Vector2(x2, y4);
          vec[3] = new SharpDX.Vector2(x1, y2);
          
          snk = geo.Open();
          snk.BeginFigure(vec[0], new SharpDX.Direct2D1.FigureBegin());
          snk.AddLines(new SharpDX.Vector2[] { vec[1], vec[2], vec[3] });
          snk.EndFigure(new SharpDX.Direct2D1.FigureEnd());
          snk.Close();
          
          RenderTarget.FillGeometry(geo, geoBrush);
          
          geo.Dispose();
          snk.Dispose();
          Cheers,
          Mike

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by PhillT, Today, 02:16 PM
          2 responses
          3 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by Kaledus, Today, 01:29 PM
          3 responses
          9 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by frankthearm, Yesterday, 09:08 AM
          14 responses
          47 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by gentlebenthebear, Today, 01:30 AM
          2 responses
          14 views
          0 likes
          Last Post gentlebenthebear  
          Started by PaulMohn, Today, 12:36 PM
          2 responses
          17 views
          0 likes
          Last Post PaulMohn  
          Working...
          X