Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

drawing options in onrender

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

    drawing options in onrender

    Hello, i am using the sharpDX tools in onrender eg DrawEllipse.

    All is well and good.

    What i now want to do/achieve is to draw a circle/ellipse and fill it with 2 or max 3 colors.

    I investigated the radialGradientBrush approach and setting the GradientStops but that i dont think will have the effect of what i want.

    I could overlay a filled circle ontop of another but that is not really what i want.

    Ideally i would like to see a pie chart effect - do i need to or is my only option to use the path geometry to achieve this. And if so i see in the MSDN specs of path geometry of the Graphics model there is a pathGradientBrush - but i dont see this in Ninja 8 ?
    Or do i just specify the colors to be used ie 2 or 3 in a different way.

    Is there any request to provide ability to draw an Arc in onrender or expand the current list of drawing tools for onrender?

    please advise
    thanks

    #2
    Hello explorer101,

    Thanks for the post.

    PathGradientBrushes do not exist with SharpDX. You could use DrawGeometry/FillGeometry with your own PathGeometry for each "shape" of your Pie Chart to give the desired effect. Additionally, you may create arcs with PathGeometry which could be used for the edge of your pie chart.

    LinearGradientBrushes or RadialGradientBrushes could also apply a gradient effect on the shapes. For example, you could use the same center point for the RadialGradientBrushes with different gradients to have a neat effect.

    All of the OnRender code is SharpDX and is not developed by NinjaTrader. As such, the documentation is provided as-is and reserved for advanced users wanting to do their own rendering. Usually, the MSDN DirectX10 reference will provide more reading on these items although the code examples would not be for C#.

    We do have GeometrySink.AddArc outlined in the help guide very briefly where the properties are explained: https://ninjatrader.com/support/help...ink_addarc.htm

    The NinjaTrader DrawingTool's are built on top of SharpDX and could be used for further reference for using PathGeometry with SharpDX. Region and Polygon are 2 examples.

    If there is anything else we can do to help, please let us know.

    Comment


      #3
      Thanks Jim, yes i understand this is MSDN documented for SharpDX.

      Regarding the radialgradientbrushes etc and radialgradientproperties ... is the center and gradientoriginoffset are these absolute values .... ie not relative between 0 and 1
      and the radius x and y of the brush are absolute values.
      I was playing around with these values looking at examples .. but seemed with pathgeometry examples the contrast was clearer but this was with pathgeometrybrush which as you said is not available in sharpdx. There doesnt seem to be much in way of examples at all for sharpDX radialgradientbrushes

      other than the drawing tools do you have any examples of the pathgeometry or drawgeomtry/fillgeometry ? i did look at region code

      thanks

      Comment


        #4
        Hello explorer101,

        The Center and GrdientOriginOffset properties are SharpDX.Vector2's. These are just coordinates that would exist somewhere on the ChartPanel. The following example would be the center of the ChartPanel:

        Code:
        SharpDX.Direct2D1.RadialGradientBrushProperties rgbProps = new SharpDX.Direct2D1.RadialGradientBrushProperties();
        rgbProps.Center = new SharpDX.Vector2(ChartPanel.W/2, ChartPanel.H/2);
        rgbProps.RadiusX = ChartPanel.W/2;
        rgbProps.RadiusY = ChartPanel.W/2;
        GradientStops are described as a float between 0 and 1, 0 being the center and 1 being the outermost end of the gradient.

        I've also included examples for LinearGradientBrushes and RadialGradientBrushes. If you are looking for additional reference for PathGeometry, you may check the DrawGeometry and FillGeometry overloads I have in my pet project SharpDX wrapper if the implementations there can provide more clarification. The concept is essentially that you will create a shape by calling AddLine or AddArc, etc. to draw the segments of your figure.

        One client (gregid) had tried to recreate PathGradientBrushes and the best solution we found at the time was to use SolidColorBrushes (The client was trying to create a heat map by recreating PathGradientBrushes.) I'll link the indicators that I converted that use this approach in case it is of use for your needs.

        SwamiStochastics - https://ninjatrader.com/support/foru...php?linkid=973
        SwamiWave - https://ninjatrader.com/support/foru...php?linkid=972

        My SharpDX wrapper (NT unsupported, but may provide direction for SharpDX needs) - https://ninjatrader.com/support/foru...hp?linkid=1135

        If there is anything else we can do to help, please let us know.
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X