Skip to content

RGB

This page is about the RGB class available in PeyrSharp.Core.Converters. You can find here all of its methods and properties.

Compatibility

The RGB class is part of the PeyrSharp.Core module, which is compatible with all of these frameworks and platforms:

Package/PlatformWindowsmacOSLinux + others
Core
Framework.NET 6.NET 7.NET 8
Core

Constructors

RGB(color)

Definition

Initializes a RGB class from a System.Drawing.Color. Returns a RGB class.

Arguments

TypeNameMeaning
ColorcolorThe RGB color.

Usage

c#
using PeyrSharp.Core.Converters;
using System.Drawing;

RGB rgb = new(Color.FromArgb(255, 150, 120));

RGB(r, g, b)

Definition

Initializes a RGB class from its r, g and b values. Returns a RGB class.

Arguments

TypeNameMeaning
intrRed.
intgGreen.
intbBlue.

WARNING

If you specify a value that is not between 0 and 255, a RGBInvalidValueException will be thrown.

Usage

c#
using PeyrSharp.Core.Converters;

RGB rgb = new(255, 150, 120);

Methods

ToHex()

Definition

Converts the RGB color to hexadecimal (HEX). Returns a HEX class.

Arguments

This method has no arguments.

Usage

c#
using PeyrSharp.Core.Converters;

HEX hex = new RGB(255, 0, 0).ToHex();

ToHsv()

Definition

Converts the RGB color to HSV. Returns a HSV class.

Arguments

This method has no arguments.

Usage

c#
using PeyrSharp.Core.Converters;

HSV hsv = new RGB(255, 0, 0).ToHsv();

Properties

Color

Definition

c#
public Color Color { get; init; }

The Color property contains the RGB color as a System.Drawing.Color. You can only get this property.

Released under the MIT License.