Views User Guides > Foundation > Graphic Resources > IlvPattern and IlvColorPattern: The Pattern Classes
IlvPattern and IlvColorPattern: The Pattern Classes
A pattern can be of any size and either monochrome, defined with only one bit per pixel, or colored. For details see:
Monochrome Patterns
Monochrome patterns are handled by the IlvPattern class. Two constructors are provided that you can use depending on the data available:
IlvPattern(IlvDisplay* display,
IlvDim w,
IlvDim h,
unsigned char* data);
IlvPattern(IlvBitmap* bitmap);
The first constructor initializes a new IlvPattern object with a pattern w pixels wide and h pixels high, filled in by the data stored in the data array of bit values. The pixel values are packed into 16-bit words from left to right in a most-significant-bits-first manner, and each scan line, stored from top to bottom, must be padded to 16 bits.
The second constructor initializes a new IlvPattern object from the given bitmap monochrome image.
To obtain a previously defined pattern, use the member function IlvDisplay::getPattern.
Other patterns are predefined within Views, which you can access by name.
Predefined Pattern Resources
Note that patterns can have a monochrome color, along with a background of a different color. To do so, draw the pattern with IlvPalette. The palette's foreground color defines the pattern's color and, if palette's fill style is set to IlvFillMaskPattern, the pattern's background is transparent. Set the fill style to IlvFillPattern in order to reveal the palette's background color.
For instance:
IlvPalette* patternPalette = display->getPalette(
display->getColor("yellow"),
display->getColor("red"),
display->getPattern("diagrl"),
0,
0,
0,
0,
IlvFillPattern
);
patternPalette->lock();
object->setPalette(patternPalette);
Multi-color patterns
Patterns can also have many colors when they are represented by instances of the IlvColorPattern class.
Published date: 05/24/2022
Last modified date: 05/24/2022