@@ -125,6 +125,72 @@ public override bool Equals(object obj)
125125 }
126126#endif
127127
128+ /// <summary>
129+ /// Gets a representation of the current instance in the format <c>rgb(RRR, GGG, BBB)</c>.
130+ /// </summary>
131+ /// <remarks>
132+ /// <para>
133+ /// The characters <c>RRR</c>, <c>GGG</c> and <c>BBB</c> in the format example correpsond to three decimal
134+ /// unsigned byte values (0 to 255) which indicate the red, green and blue components of the color respectively.
135+ /// </para>
136+ /// <para>
137+ /// Note that this format omits the alpha (transparency) component of the color. Thus, the resulting string
138+ /// will not be equal to the <see cref="Color"/> value which created it if the alpha component is not equal to 1.
139+ /// The only string-formatting methods which preserve all of the information in the color instance are
140+ /// <see cref="ToRgbaString"/> and the default <see cref="ToString"/> method, which both return equivalent results.
141+ /// </para>
142+ /// </remarks>
143+ /// <returns>An RGB-format string.</returns>
144+ public string ToRgbString ( ) => $ "rgb({ Red } , { Green } , { Blue } )";
145+
146+ /// <summary>
147+ /// Gets a representation of the current instance in the format <c>rgba(RRR, GGG, BBB, A)</c>.
148+ /// </summary>
149+ /// <remarks>
150+ /// <para>
151+ /// The characters <c>RRR</c>, <c>GGG</c> and <c>BBB</c> in the format example correpsond to three decimal
152+ /// unsigned byte values (0 to 255) which indicate the red, green and blue components of the color respectively.
153+ /// The character <c>A</c> corresponds to the alpha (transparency) component of the color. It will be either
154+ /// the numbers 1 or 0, or it will be a decimal number between one and zero.
155+ /// </para>
156+ /// <para>
157+ /// Out of the string-formatting methods available on the <see cref="Color"/> type, only this one and the default
158+ /// <see cref="ToString"/> method preserve all information in the color instance. Thus this method may be used
159+ /// alongside <see cref="Parse"/> or <see cref="TryParse(string, out Color)"/> to reliably round-trip an RGBA
160+ /// string color representation.
161+ /// </para>
162+ /// </remarks>
163+ /// <returns>An RGBA-format string.</returns>
164+ public string ToRgbaString ( ) => $ "rgba({ Red } , { Green } , { Blue } , { Alpha } )";
165+
166+ /// <summary>
167+ /// Gets a representation of the current instance in the format <c>#RRGGBB</c>.
168+ /// </summary>
169+ /// <remarks>
170+ /// <para>
171+ /// The characters <c>RR</c>, <c>GG</c> and <c>BB</c> in the format example correpsond to three hexadecimal
172+ /// unsigned byte values (00 to FF, corresponding to decimal 0 to 255). These indicate the red, green and
173+ /// blue components of the color respectively.
174+ /// </para>
175+ /// <para>
176+ /// Note that this format omits the alpha (transparency) component of the color. Thus, the resulting string
177+ /// will not be equal to the <see cref="Color"/> value which created it if the alpha component is not equal to 1.
178+ /// The only string-formatting methods which preserve all of the information in the color instance are
179+ /// <see cref="ToRgbaString"/> and the default <see cref="ToString"/> method, which both return equivalent results.
180+ /// </para>
181+ /// </remarks>
182+ /// <returns>An RGB-format string.</returns>
183+ public string ToHexString ( ) => $ "#{ Red : X} { Green : X} { Blue : X} ";
184+
185+ /// <summary>
186+ /// Returns a string in the same format as <see cref="ToRgbaString"/>.
187+ /// </summary>
188+ /// <remarks>
189+ /// <para>This method and <see cref="ToRgbaString"/> are equivalent.</para>
190+ /// </remarks>
191+ /// <returns>An RGBA-format string.</returns>
192+ public override string ToString ( ) => ToRgbaString ( ) ;
193+
128194 /// <inheritdoc/>
129195 public override int GetHashCode ( ) => HashCode . Combine ( Red , Green , Blue , Alpha ) ;
130196
0 commit comments