Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Documentation: SharpDX.Color4

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

    Documentation: SharpDX.Color4

    It's important to note that the alpha value of SharpDX.Color4 should be a float between 0 and 1.0, just like opacity values. In the example, 50 would make the color completely opaque, as would any value >=1. Therefore, the data type of alpha cannot be byte or int if you want it to behave as expected. This, of course, is different than the range of alpha values between 0 and 255 we use for Windows.Media.Brush WPF colors.

    http://ninjatrader.com/support/helpG..._rendering.htm
    Code:
    // create a 3 component color using rgb values
     SharpDX.Color3 dxColor3 = new SharpDX.Color3(255, 0, 0);
    // create a 4 component color using rgb + alpha (transparency)
    SharpDX.Color4 dxColor4 = new SharpDX.Color4(dxColor3, [COLOR=Red][B]50[/B][/COLOR]); [COLOR=SeaGreen]// should be 0.5[/COLOR]
    // solid color brush uses a Color4 during construction
    SharpDX.Direct2D1.SolidColorBrush argbColorBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, dxColor4);

    #2
    Thank you for your report, tradesmart. This information has been passed on to the responsible teams, who will update the help guide accordingly.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      And not only alpha values, but R, G, and B values also need to be floats. When converting from WPF brushes to SharpDX, you will need to divide each byte value by 255 to get the proper float values for SharpDX as shown in the attached image.
      Attached Files

      Comment


        #4
        Thank you again, tradesmart. For reference and ease of understanding I am providing an excerpt from SharpDX' source for Color4 :

        Code:
        // https://github.com/sharpdx/SharpDX/blob/master/Source/SharpDX.Mathematics/Color4.cs
        public static readonly Color4 Black = new Color4(0.0f, 0.0f, 0.0f, 1.0f);
        public static readonly Color4 White = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        44 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        180 views
        0 likes
        Last Post jeronymite  
        Started by DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        13 views
        0 likes
        Last Post DanielSanMartin  
        Working...
        X