Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Applying Opacity in the code

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

    Applying Opacity in the code

    Hi,

    One of fellow members shared an indicator and I'm trying to add opacity inside this code. But I have no idea how... I want 50% of opacity of this vertical line. I would appreciate any suggestion. Thank you

    protected override void OnBarUpdate()
    {
    if (Time[0].TimeOfDay.Minutes == 0 && (Time[0].TimeOfDay.Seconds == 00 ))
    {

    VerticalLine myLine1 = Draw.VerticalLine(this, "LineOnStart"+Time[0], 0, Brushes.White);
    myLine1.Stroke = new Stroke(Brushes.DimGray, DashStyleHelper.Dot, 1);

    }



    #2
    Hello jjanguda,

    Thanks for your post.

    What I would suggest is to create a private brush variable at the class level, for example: private Brush myBrush = Brushes.DimGray;

    To create the custom brush once, in State.DataLoaded:

    Brush temp = myBrush.Clone(); // copy current brush
    temp.Opacity = 50.0/100.0; // 50% opacity
    temp.Freeze(); // required to freeze
    myBrush = temp; // assign 50% opaque brush to user brush.


    In OnBarUpdate() you would use myBrush where you are currently specifying a brush.

    Note: The brush is created in state data loaded so that it is only created once.


    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    86 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    125 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    64 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    117 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X