ColorRGB class Color Component Styling

Represents a true color (24-bit RGB) ANSI color.

Supports generating ANSI escape sequences for foreground and background colors in the RGB format, along with dimming support.

Properties

  • r, g, b: Red, Green, Blue components (0-255).

Responsibilities

  • Provide RGB ANSI escape codes for foreground and background.
  • Support dimming of RGB colors.
  • Provide printable hex string representation.

Example

final redRgb = ColorRGB(255, 0, 0);
print(redRgb.fg);         // Outputs: "38;2;255;0;0"
print(redRgb.printableFg); // Outputs: "#ff0000"
final dimmed = redRgb.dimmed();
print(dimmed.fg);          // Outputs dimmed RGB code.

See Also

Implemented types

Constructors

ColorRGB.new(int r, int g, int b)
Creates a true color RGB color with the given components.
const

Properties

b int
The blue component of the RGB color (0-255).
final
bg String
Returns the ANSI escape sequence for the RGB background color.
no setteroverride
fg String
Returns the ANSI escape sequence for the RGB foreground color.
no setteroverride
g int
The green component of the RGB color (0-255).
final
hashCode int
Returns the hash code for this color based on its RGB components.
no setteroverride
printableBg String
Returns a hexadecimal string representation of the background color.
no setteroverride
printableFg String
Returns a hexadecimal string representation of the foreground color.
no setteroverride
r int
The red component of the RGB color (0-255).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dimmed({double dimFactor = 0.5}) ColorRGB
Returns a dimmed version of this color by scaling RGB components by dimFactor.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Returns a string representation of this RGB color.
override

Operators

operator ==(Object other) bool
Compares two ColorRGB instances for equality.
override