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 josh18955, 03-25-2023, 11:16 AM
        6 responses
        435 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        3 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        18 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frslvr, 04-11-2024, 07:26 AM
        9 responses
        127 views
        1 like
        Last Post caryc123  
        Started by selu72, Today, 02:01 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Working...
        X