The C++ platform has OdCm-classes for working with colors and transparencies of various objects. To work with colors and transparencies, use the following:
The OdCmColorBase abstract class provides the virtual base interface for classes representing colors. This class is used only for deriving color classes. Developers can not create instances of this class. Its pure virtual methods do not have an implementation and are the declaration of the color interface. Classes derived from the OdCmColorBase class must redefine its methods for working with colors. You can either implement these methods in the class that you derive or you can use the ready-to-use OdCmColor and OdCmEntityColor classes.
The OdCmEntityColor class is a ready-to-use color object that works with a color as a 32-bit packed integer value. This value stores the color method and color components together. The composition of color components depends on the color method. The OdCmEntityColor class is not a successor of the OdCmColorBase class and has static methods for working with color methods and color components.
The OdCmColor class is a ready-to-use color object that works with named and unnamed colors. This class represents a color as an object of the drawing database. The named color is represented by a name of a book that stores information about how to display the color. The unnamed color is represented by a 32-bit packed integer value that stores the color method and color components. The OdCmColor class is the successor of the OdCmColorBase class and inherits its methods. The OdCmColor class implements the pure virtual methods for working with database colors. Additionally, the OdCmColor class defines the dwgIn(), dwgOut(), dxfIn(), and dxfOut() methods that convert the color information in or from the .dwg or .dxf files. The OdCmColor class also defines the entityColor() method that converts the database color to the instance of the OdCmEntityColor class.
The color interface declares the following specific methods and operators
For working with a color method:
For working with a color as an RGB-value:
For working with a color as an ACI-value:
For working with an unnamed color:
For working with a named color:
Note: The OdCmEntityColor class has static methods. The OdCmColor class has virtual methods. You can derive a new color class from the OdCmColor class.
The OdCmTransparency class is a ready-to-use transparency object that works with transparency as a 32-bit packed integer value. This value stores the transparency method and transparency components together. The composition of transparency components depends on the transparency method. It declares the following specific methods and operators.
For working with a transparency method:
For working with a transparency as an alpha value:
For working with a transparency as an integer value:
Macros work with 32-bits integer values as with RGB-values and perform packing and extracting of color components. The ODRGB(red, green, blue) macro packs three specified color components in a RGB-value. The ODRGBA(red, green, blue, alpha) macro packs three color specified components and transparency alpha value in a 32-bit integer value. The ODGETRED(rgb) macro extracts the red component value from the specified RGB-value. The ODGETGREEN(rgb) macro extracts the green component value from the specified RGB-value. The ODGETBLUE(rgb) macro extracts the blue component value from the specified RGB-value. The ODGETALPHA(rgba) macro extracts the alpha component value from the specified RGB-value. Use these macros when you work with colors as integer values.
The OdCm-classes allow you to manipulate the color and transparency of various objects using the represented interfaces.
Working with Colors and Transparencies
Methods of the Color Definition
Methods of the Transparency Definition
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|