Question

I can create an opacity mask in WPF using a LinearGradientBrush as follows

    <LinearGradientBrush x:Key="SplitterOpactityMask" StartPoint="0,0" EndPoint="1,0">
        <GradientStop Color="#FFFFFFFF" Offset="0"/>
        <GradientStop Color="#00FFFFFF" Offset="1"/>
    </LinearGradientBrush>

This gives me a brush starting from zero transparency to full transparency over the range of brush.

However what hex codes are used to give different levels of transparency? For example I want to start my brush at 75% transparency and then go to 100% of the range of the brush.

Was it helpful?

Solution

As documented the OpacityMask uses the alpha channel from the specified brush. If you're asking which part of the hex you are specifying for the color represents the alpha then it is the 1st 2 hex characters of the 8 hex color code (i.e. #aarrggbb). So FF is fully opaque and 00 is fully transparent. So 75% transparency (i.e. 25% opaque) would be 0x40 (255 * .25).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top