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