ColorSwatchGroup Manual
A
ColorSwatchGroup
stores multiple colors as
maxon::ColorA
. The group itself and the colors can be selected.
ColorSwatchGroup
elements are stored and handled using
ColorSwatchData
objects. The class is defined in the
lib_colorchooser.h
header file.
// load document color swatches ColorSwatchData * const colorSwatchData = ColorSwatchData::Alloc (doc, false ); if (colorSwatchData == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// AutoFree takes ownership AutoFree<ColorSwatchData> freeData; freeData. 赋值 (colorSwatchData);
// loop through groups const Int groupCount = colorSwatchData-> GetGroupCount ();
// get color and check if it is selected if (group-> GetColor (c, color, &selected) && selected) { // create new material 材质 * const mat = Material::Alloc (); if (mat == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// use color const 向量 rgb { color. r , color. g , color. b }; mat-> SetParameter ( MATERIAL_COLOR_COLOR , rgb, DESCFLAGS_SET::NONE ); doc-> InsertMaterial (mat); } } } }
ColorSwatchGroups can be created using the usual tools. This is typically not needed.
ColorSwatchGroup elements are stored in a ColorSwatchData object. See ColorSwatchData Color Groups
A ColorSwatchGroup can be selected:
// check if a group could be accessed // and if that group is selected if (group-> IsGroupSelected ()) { ApplicationOutput ( "Group " + group-> GetName () + " is selected." ); } }
A ColorSwatchGroup can be identified by a name:
A ColorSwatchGroup stores multiple colors and their selection state. The colors are obtained with:
// access the color with the index 'c' if (!group-> GetColor (c, color)) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); ApplicationOutput ( "Color: @" , color); }
Colors can be edited with:
New colors are added with:
The selection status of a color can be utilized with these functions:
Further utility functions are: