static Color FromRgb( System.UInt32 rgb )

book_4_sparkGenerated
code_blocksInput

Description

The Color.FromRgb method creates a Color instance from a 32-bit unsigned integer representing the RGB color components. The integer should be formatted as 0xRRGGBB, where RR, GG, and BB are the red, green, and blue components respectively.

Usage

Use this method when you have a color represented as a 32-bit unsigned integer and you need to convert it to a Color object. This is particularly useful when dealing with color data stored in a compact format, such as in graphics programming or when interfacing with APIs that use this format.

Example

// Example of using Color.FromRgb
uint rgbValue = 0xFF5733; // Represents a color with red, green, and blue components
Color color = Color.FromRgb(rgbValue);

// Accessing the color components
float red = color.r;   // Red component
float green = color.g; // Green component
float blue = color.b;  // Blue component

// Output the color components
// Note: Avoid using Console.WriteLine in s&box, use logging or debugging tools instead
// Log.Info($"Red: {red}, Green: {green}, Blue: {blue}");