Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Struct

OfficeColor

OfficeIMO

Namespace
OfficeIMO
Assembly
OfficeIMO.Core
Source revision
e163ccb36643 with working tree changes
Base
ValueType
Implements
IEquatable<OfficeColor>
Modifiers
sealed

Immutable literal RGBA color or theme-role reference shared by OfficeIMO packages.

Inheritance

  • ValueType
  • OfficeColor

Remarks

RGB byte getters and literal hexadecimal/CSS formatting project normalized channels to bytes. Use OfficeColor.ToNormalizedRgb to read the retained normalized RGB values without that projection.

Usage

Explore 426 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 206

Accepted by parameters 220

Constructors

public OfficeColor(byte r, byte g, byte b, byte a = 255) #

Creates an RGBA color from byte channels.

Parameters

r byte required
g byte required
b byte required
a byte = 255 optional

Methods

Equals 2 overloads
public bool Equals(OfficeColor other) #

Indicates whether the current object is equal to another object of the same type.

Parameters

other OfficeIMO.OfficeColor required
An object to compare with this object.

Returns

bool true if the current object is equal to the other parameter; otherwise, false.
public override bool Equals(object? obj) #

Indicates whether this instance and a specified object are equal.

Parameters

obj object? required
The object to compare with the current instance.

Returns

bool true if obj and this instance are the same type and represent the same value; otherwise, false.
public static OfficeColor FromNormalizedRgb(double r, double g, double b, byte alpha = 255) #

Creates a literal color retaining normalized RGB channels and a byte alpha channel.

Parameters

r double required
Finite red channel in the inclusive 0..1 range.
g double required
Finite green channel in the inclusive 0..1 range.
b double required
Finite blue channel in the inclusive 0..1 range.
alpha byte = 255 optional
Alpha byte, from 0 (transparent) to 255 (opaque).

Returns

OfficeColor A literal color whose normalized RGB channels preserve the supplied values.

Exceptions

  • ArgumentOutOfRangeException – An RGB channel is not finite or is outside 0..1.
public static OfficeColor FromRgb(byte r, byte g, byte b) #

Creates an opaque color from RGB components.

Parameters

r byte required
g byte required
b byte required
public static OfficeColor FromRgba(byte r, byte g, byte b, byte a) #

Creates a color from RGBA components.

Parameters

r byte required
g byte required
b byte required
a byte required
public override int GetHashCode() #

Returns the hash code for this instance.

Returns

int A 32-bit signed integer that is the hash code for this instance.
public static bool op_Equality(OfficeColor left, OfficeColor right) #

Equality operator.

Parameters

left OfficeIMO.OfficeColor required
right OfficeIMO.OfficeColor required

Returns

bool
public static bool op_Inequality(OfficeColor left, OfficeColor right) #

Inequality operator.

Parameters

left OfficeIMO.OfficeColor required
right OfficeIMO.OfficeColor required

Returns

bool
public static OfficeColor Parse(string value) #

Parses a theme role, named color, #RRGGBB, RRGGBB, #RRGGBBAA, or RRGGBBAA.

Parameters

value string required
public static OfficeColor ParseCss(string value) #

Parses a CSS named, hexadecimal, legacy, or CSS Color Level 4 color. Both legacy comma syntax and modern space/slash syntax are accepted.

Parameters

value string required
public static OfficeColor ParseHex(string value) #

Parses a hexadecimal color value.

Parameters

value string required
public OfficeColor Resolve(OfficeTheme theme) #

Resolves a role to a literal RGBA color using the supplied theme; literals are returned unchanged.

Parameters

theme OfficeIMO.OfficeTheme required
public string ToArgbHex() #

Returns the byte projection as AARRGGBB; normalized RGB precision is not serialized.

Returns

string
public string ToCssColor() #

Returns the byte projection as a CSS hexadecimal color using #RRGGBB or #RRGGBBAA notation.

Returns

string
public string ToHex() #

Returns the byte projection as RRGGBBAA; normalized RGB precision is not serialized.

Returns

string
public ValueTuple<double, double, double> ToNormalizedRgb() #

Returns literal RGB channels in the 0..1 range without projecting retained normalized values to bytes.

Returns

ValueTuple<double, double, double> The retained normalized channels, or byte channels divided by 255D for byte literals.

Exceptions

  • InvalidOperationException – This color is an unresolved theme role.
public string ToRgbHex() #

Returns the byte projection as RRGGBB; normalized RGB precision is not serialized.

Returns

string
public override string ToString() #

Returns the fully qualified type name of this instance.

Returns

string The fully qualified type name.
public static bool TryParse(string? value, out OfficeColor color) #

Tries to parse a theme role, named or hexadecimal color value.

Parameters

value string? required
color OfficeIMO.OfficeColor required

Returns

bool
public static bool TryParseCss(string? value, out OfficeColor color) #

Tries to parse a CSS named, hexadecimal, legacy, or CSS Color Level 4 color. Out-of-range numeric channels are clamped as required by CSS color serialization.

Parameters

value string? required
color OfficeIMO.OfficeColor required

Returns

bool
public static bool TryParseHex(string? value, out OfficeColor color) #

Tries to parse a hexadecimal color value.

Parameters

value string? required
color OfficeIMO.OfficeColor required

Returns

bool

Properties

public OfficeColorRole Role { get; } #

Gets the semantic role, or None for a literal.

public byte R { get; } #

Red byte component, projected for normalized literals; resolve theme roles before reading.

public byte G { get; } #

Green byte component, projected for normalized literals.

public byte B { get; } #

Blue byte component, projected for normalized literals.

public byte A { get; } #

Alpha byte component.

public static OfficeColor Transparent { get; } #

Gets fully transparent black (#00000000).

public static OfficeColor AliceBlue { get; } #

Gets the AliceBlue named color (#F0F8FF).

public static OfficeColor Aqua { get; } #

Gets the Aqua named color (#00FFFF).

public static OfficeColor Aquamarine { get; } #

Gets the Aquamarine named color (#7FFFD4).

public static OfficeColor Azure { get; } #

Gets the Azure named color (#F0FFFF).

public static OfficeColor Beige { get; } #

Gets the Beige named color (#F5F5DC).

public static OfficeColor Black { get; } #

Gets the Black named color (#000000).

public static OfficeColor Blue { get; } #

Gets the Blue named color (#0000FF).

public static OfficeColor BlueViolet { get; } #

Gets the BlueViolet named color (#8A2BE2).

public static OfficeColor Brown { get; } #

Gets the Brown named color (#A52A2A).

public static OfficeColor Coral { get; } #

Gets the Coral named color (#FF7F50).

public static OfficeColor CornflowerBlue { get; } #

Gets the CornflowerBlue named color (#6495ED).

public static OfficeColor Crimson { get; } #

Gets the Crimson named color (#DC143C).

public static OfficeColor Cyan { get; } #

Gets the Cyan named color (#00FFFF).

public static OfficeColor DarkBlue { get; } #

Gets the DarkBlue named color (#00008B).

public static OfficeColor DarkCyan { get; } #

Gets the DarkCyan named color (#008B8B).

public static OfficeColor DarkGoldenrod { get; } #

Gets the DarkGoldenrod named color (#B8860B).

public static OfficeColor DarkGray { get; } #

Gets the DarkGray named color (#A9A9A9).

public static OfficeColor DarkGreen { get; } #

Gets the DarkGreen named color (#006400).

public static OfficeColor DarkKhaki { get; } #

Gets the DarkKhaki named color (#BDB76B).

public static OfficeColor DarkMagenta { get; } #

Gets the DarkMagenta named color (#8B008B).

public static OfficeColor DarkOliveGreen { get; } #

Gets the DarkOliveGreen named color (#556B2F).

public static OfficeColor DarkOrange { get; } #

Gets the DarkOrange named color (#FF8C00).

public static OfficeColor DarkRed { get; } #

Gets the DarkRed named color (#8B0000).

public static OfficeColor DarkSalmon { get; } #

Gets the DarkSalmon named color (#E9967A).

public static OfficeColor DarkSeaGreen { get; } #

Gets the DarkSeaGreen named color (#8FBC8F).

public static OfficeColor DarkSlateBlue { get; } #

Gets the DarkSlateBlue named color (#483D8B).

public static OfficeColor DeepPink { get; } #

Gets the DeepPink named color (#FF1493).

public static OfficeColor DimGray { get; } #

Gets the DimGray named color (#696969).

public static OfficeColor DimGrey { get; } #

Gets the British-spelling alias for OfficeColor.DimGray.

public static OfficeColor DodgerBlue { get; } #

Gets the DodgerBlue named color (#1E90FF).

public static OfficeColor ForestGreen { get; } #

Gets the ForestGreen named color (#228B22).

public static OfficeColor Gold { get; } #

Gets the Gold named color (#FFD700).

public static OfficeColor Goldenrod { get; } #

Gets the Goldenrod named color (#DAA520).

public static OfficeColor Gray { get; } #

Gets the Gray named color (#808080).

public static OfficeColor Green { get; } #

Gets the Green named color (#008000).

public static OfficeColor GreenYellow { get; } #

Gets the GreenYellow named color (#ADFF2F).

public static OfficeColor Honeydew { get; } #

Gets the Honeydew named color (#F0FFF0).

public static OfficeColor HotPink { get; } #

Gets the HotPink named color (#FF69B4).

public static OfficeColor IndianRed { get; } #

Gets the IndianRed named color (#CD5C5C).

public static OfficeColor Indigo { get; } #

Gets the Indigo named color (#4B0082).

public static OfficeColor Khaki { get; } #

Gets the Khaki named color (#F0E68C).

public static OfficeColor Lavender { get; } #

Gets the Lavender named color (#E6E6FA).

public static OfficeColor LightBlue { get; } #

Gets the LightBlue named color (#ADD8E6).

public static OfficeColor LightCoral { get; } #

Gets the LightCoral named color (#F08080).

public static OfficeColor LightCyan { get; } #

Gets the LightCyan named color (#E0FFFF).

public static OfficeColor LightGoldenrodYellow { get; } #

Gets the LightGoldenrodYellow named color (#FAFAD2).

public static OfficeColor LightGray { get; } #

Gets the LightGray named color (#D3D3D3).

public static OfficeColor LightGreen { get; } #

Gets the LightGreen named color (#90EE90).

public static OfficeColor LightPink { get; } #

Gets the LightPink named color (#FFB6C1).

public static OfficeColor LightSkyBlue { get; } #

Gets the LightSkyBlue named color (#87CEFA).

public static OfficeColor LightSteelBlue { get; } #

Gets the LightSteelBlue named color (#B0C4DE).

public static OfficeColor LightYellow { get; } #

Gets the LightYellow named color (#FFFFE0).

public static OfficeColor Lime { get; } #

Gets the Lime named color (#00FF00).

public static OfficeColor Magenta { get; } #

Gets the Magenta named color (#FF00FF).

public static OfficeColor Maroon { get; } #

Gets the Maroon named color (#800000).

public static OfficeColor MediumAquamarine { get; } #

Gets the MediumAquamarine named color (#66CDAA).

public static OfficeColor MediumPurple { get; } #

Gets the MediumPurple named color (#9370DB).

public static OfficeColor MediumVioletRed { get; } #

Gets the MediumVioletRed named color (#C71585).

public static OfficeColor MistyRose { get; } #

Gets the MistyRose named color (#FFE4E1).

public static OfficeColor Navy { get; } #

Gets the Navy named color (#000080).

public static OfficeColor Olive { get; } #

Gets the Olive named color (#808000).

public static OfficeColor Orange { get; } #

Gets the Orange named color (#FFA500).

public static OfficeColor OrangeRed { get; } #

Gets the OrangeRed named color (#FF4500).

public static OfficeColor Peru { get; } #

Gets the Peru named color (#CD853F).

public static OfficeColor Pink { get; } #

Gets the Pink named color (#FFC0CB).

public static OfficeColor Plum { get; } #

Gets the Plum named color (#DDA0DD).

public static OfficeColor Purple { get; } #

Gets the Purple named color (#800080).

public static OfficeColor RebeccaPurple { get; } #

Gets the RebeccaPurple named color (#663399).

public static OfficeColor Red { get; } #

Gets the Red named color (#FF0000).

public static OfficeColor SaddleBrown { get; } #

Gets the SaddleBrown named color (#8B4513).

public static OfficeColor Salmon { get; } #

Gets the Salmon named color (#FA8072).

public static OfficeColor SandyBrown { get; } #

Gets the SandyBrown named color (#F4A460).

public static OfficeColor SeaGreen { get; } #

Gets the SeaGreen named color (#2E8B57).

public static OfficeColor Silver { get; } #

Gets the Silver named color (#C0C0C0).

public static OfficeColor SkyBlue { get; } #

Gets the SkyBlue named color (#87CEEB).

public static OfficeColor SteelBlue { get; } #

Gets the SteelBlue named color (#4682B4).

public static OfficeColor Teal { get; } #

Gets the Teal named color (#008080).

public static OfficeColor Wheat { get; } #

Gets the Wheat named color (#F5DEB3).

public static OfficeColor White { get; } #

Gets the White named color (#FFFFFF).

public static OfficeColor WhiteSmoke { get; } #

Gets the WhiteSmoke named color (#F5F5F5).

public static OfficeColor Yellow { get; } #

Gets the Yellow named color (#FFFF00).

public static OfficeColor YellowGreen { get; } #

Gets the YellowGreen named color (#9ACD32).

public bool IsThemeRole { get; } #

Gets whether resolution against a theme is required.

public string? ThemeSlot { get; } #

Gets the native DrawingML slot (accent1-6, dk1, dk2 or lt1), or null for a literal/status role.

public static OfficeColor Accent1 { get; } #

Gets a reference to the first accent.

public static OfficeColor Accent2 { get; } #

Gets a reference to the second accent.

public static OfficeColor Accent3 { get; } #

Gets a reference to the third accent.

public static OfficeColor Accent4 { get; } #

Gets a reference to the fourth accent.

public static OfficeColor Accent5 { get; } #

Gets a reference to the fifth accent.

public static OfficeColor Accent6 { get; } #

Gets a reference to the sixth accent.

public static OfficeColor Text { get; } #

Gets a reference to primary text.

public static OfficeColor TextMuted { get; } #

Gets a reference to muted text.

public static OfficeColor Background { get; } #

Gets a reference to the background.

public static OfficeColor Success { get; } #

Gets a positive-status color resolved at write time.

public static OfficeColor Warning { get; } #

Gets a warning-status color resolved at write time.

public static OfficeColor Danger { get; } #

Gets a danger-status color resolved at write time.

Extension Methods

public static string ToHexColor(OfficeColor color) #

Converts a color to a hexadecimal RRGGBB value.

Parameters

color OfficeIMO.OfficeColor required

Returns

string