@mlightcad/common
Version:
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@mlightcad/common)
119 lines • 3.28 kB
TypeScript
import { AcCmColorMethod } from './AcCmColorMethod';
/**
* Represents an AutoCAD-like entity color object.
*
* This class mimics ObjectARX `AcCmEntityColor`. It stores:
* - A color method (`AcCmColorMethod`)
* - A single numeric `value` that represents:
* - RGB (packed R/G/B)
* - ACI index
* - Layer index
*
* It uses lazy decoding/encoding to expose convenient getters/setters.
*/
export declare class AcCmEntityColor {
/**
* The method used to determine the final color.
* Defaults to `AcCmColorMethod.ByColor` (RGB).
*/
_colorMethod: AcCmColorMethod;
/**
* Internal value storing either:
* - Packed RGB: (R << 16) | (G << 8) | B
* - ACI color index
* - Layer index
*/
private _value;
/**
* Constructs a new `AcCmEntityColor`.
*
* @param method Initial color method (defaults to `ByColor`)
* @param value Internal packed value (defaults to `0`)
*/
constructor(method?: AcCmColorMethod, value?: number);
/**
* Gets the method used to determine the final color.
*/
get colorMethd(): AcCmColorMethod;
/**
* Gets the red component (0–255). Only valid when colorMethod = ByColor.
*/
get red(): number;
/**
* Sets the red component and updates the packed RGB value.
*/
set red(v: number);
/**
* Gets the green component (0–255). Only valid when colorMethod = ByColor.
*/
get green(): number;
/**
* Sets the green component and updates the packed RGB value.
*/
set green(v: number);
/**
* Gets the blue component (0–255). Only valid when colorMethod = ByColor.
*/
get blue(): number;
/**
* Sets the blue component and updates the packed RGB value.
*/
set blue(v: number);
/**
* Sets all RGB components.
*
* @param r Red (0–255)
* @param g Green (0–255)
* @param b Blue (0–255)
*/
setRGB(r: number, g: number, b: number): void;
/**
* Gets the AutoCAD Color Index (ACI). Only valid when colorMethod = ByACI.
*/
get colorIndex(): number;
/**
* Sets the AutoCAD Color Index (ACI).
*/
set colorIndex(index: number);
/**
* Gets the referenced layer index. Only valid when colorMethod = ByLayer.
*/
get layerIndex(): number;
/**
* Sets the layer index for ByLayer color mode.
*/
set layerIndex(index: number);
/**
* Returns true if the color method is ByColor (explicit RGB).
*/
isByColor(): boolean;
/**
* Returns true if the color method is ByLayer.
*/
isByLayer(): boolean;
/**
* Returns true if the color method is ByBlock.
*/
isByBlock(): boolean;
/**
* Returns true if the color method is ByACI.
*/
isByACI(): boolean;
/**
* Returns true if color is uninitialized or invalid.
*/
isNone(): boolean;
/**
* Gets the packed internal value.
*
* - RGB → packed 24-bit integer
* - ACI → index
* - Layer → index
*/
get rawValue(): number;
/**
* Sets a raw internal value. The meaning depends on `colorMethod`.
*/
set rawValue(v: number);
}
//# sourceMappingURL=AcCmEntityColor.d.ts.map