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 elirion, Today, 01:36 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by DJ888, 04-16-2024, 06:09 PM
        5 responses
        14 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by samish18, Yesterday, 08:31 AM
        4 responses
        14 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by funk10101, Yesterday, 09:43 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        5 responses
        551 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X