• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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().
    http://ninjatrader.com/support/helpG...s/onrender.htm

    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.
    http://stackoverflow.com/questions/2...points-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.
        http://stackoverflow.com/questions/2...points-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 dpolyakov, Today, 01:13 PM
          2 responses
          9 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by tjendra, Today, 12:15 PM
          2 responses
          7 views
          0 likes
          Last Post tjendra
          by tjendra
           
          Started by lunardiplomacy, Today, 11:46 AM
          4 responses
          15 views
          0 likes
          Last Post lunardiplomacy  
          Started by trdninstyle, Today, 10:38 AM
          2 responses
          17 views
          0 likes
          Last Post trdninstyle  
          Started by momchi, Yesterday, 09:19 PM
          2 responses
          21 views
          0 likes
          Last Post NinjaTrader_Jim  
          Working...
          X