Back to top OpenSVG (c) Veridict AB, www.veridict.com
Edit this page

Class ColorExtensions

Provides extension methods for SKColor to support hexadecimal color codes.

Inheritance
object
ColorExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: OpenSvg
Assembly: OpenSvg.dll
Syntax
public static class ColorExtensions

Properties

| Edit this page View Source

Transparent

Gets a SKColor that represents the transparent color.

Declaration
public static SKColor Transparent { get; }
Property Value
Type Description
SKColor

Methods

| Edit this page View Source

IsTransparent(SKColor)

Returns whether the specified SKColor is transparent.

Declaration
public static bool IsTransparent(this SKColor sKColor)
Parameters
Type Name Description
SKColor sKColor

The SKColor instance to check.

Returns
Type Description
bool

true if the color is transparent; otherwise, false.

| Edit this page View Source

ToColor(string)

Parses a hexadecimal color string and returns the corresponding SKColor.

Declaration
public static SKColor ToColor(this string colorString)
Parameters
Type Name Description
string colorString

The hexadecimal color string to parse.

Returns
Type Description
SKColor

A SKColor instance that corresponds to the given hexadecimal color string.

Remarks

The method accepts color strings in the following formats:

  • Hexadecimal RGB: Starts with a '#' followed by 6 hexadecimal characters (e.g., "#FF0000" for red).
  • Transparent: The string "none" to indicate a transparent color.
  • Named colors: Colors defined in SkiaSharp (e.g., "Red", "LightSkyBlue") are also supported.
The method treats input case insensitive.
Exceptions
Type Condition
ArgumentException

Thrown when the specified string is null, empty, or has an invalid format.

| Edit this page View Source

ToHexColorString(SKColor)

Returns a hexadecimal representation of the given SKColor.

Declaration
public static string ToHexColorString(this SKColor color)
Parameters
Type Name Description
SKColor color

The SKColor instance to be converted.

Returns
Type Description
string

A hexadecimal string that represents the given color.

| Edit this page View Source

ToString(SKColor)

Returns a string representation of the given SKColor.

Declaration
public static string ToString(this SKColor color)
Parameters
Type Name Description
SKColor color

The SKColor instance to be converted.

Returns
Type Description
string

A string that represents the given color.