Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X