Alpha-value is a value that defines the degree of transparency.
An Alpha-value can be defined either by an integer value in the range 0 to 255,
or a double value in the range 0.0 to 1.0, which corresponds to the range from
0 to 100 percent. Value 0 or 0.0 (0%) denotes an limpid object (clarity).
Value 255 or 1.0 (100%) denotes a filled object (opacity).
The packed integer value stores the alpha value in 0 to 7 bits.
The transparency object is declared by the following line:
OdCmTransparency clarity;
To get the alpha value as an integer value, use the alpha() method that returns the degree of
transparency in the range 0 to 255. For example:
To set the alpha value as an integer value, use the setAlpha() method that requires the
degree of transparency in the range 0 to 255 and sets the transparency method to kByAlpha. For example:
int alpha;
odPrintConsoleString(L"\nEntry a transparency degree [0...255]:>");
scanf("%d", &alpha);
if(alpha >= 0 && alpha <= 255)
{
clarity.setAlpha(alpha);
}
else odPrintConsoleString(L"Alpha is outside the scope 0...255\n");
To get the alpha value as a double value, use the alphaPercent() method that returns the degree of
transparency in the range from 0.0 to 1.0. For example:
To set the alpha value as a double value, use the setAlphaPercent() method that requires the
degree of transparency in the range 0.0 to 1.0 and sets the transparency method to kByAlpha. For example:
double percent;
odPrintConsoleString(L"\nEntry a percent of transparency degree [0...100%]:>");
scanf("%f", &percent);
if(percent >= 0.0 && percent <= 100.0)
{
clarity.setAlphaPercent(percent/100);
}
else odPrintConsoleString(L"Alpha is outside the scope 0...100%\n");
To check whether the degree of transparency denotes a limpid object, use the isClear() method that
returns True when the alpha value is set to 0 (0%) or False otherwise. For example:
To check whether the degree of transparency denotes a filled object, use the isSolid() method that
returns True when the alpha value is set to 255 (100%) or False otherwise. For example: