From e53fc18f76ca9136e06549e62d0f213079834850 Mon Sep 17 00:00:00 2001 From: Sebastian Felis Date: Fri, 21 May 2021 17:41:41 +0200 Subject: [PATCH] README file update --- README.md | 124 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 108 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 37b6a75..89ca114 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,24 @@ # DotNetColorParser [![Build Status](https://robolynx.visualstudio.com/DotNetColorParser/_apis/build/status/sebafelis.DotNetColorParser?branchName=main)](https://robolynx.visualstudio.com/DotNetColorParser/_build/latest?definitionId=6&branchName=main) -[![DotNetColorParser NuGet Package](https://img.shields.io/nuget/v/DotNetColorParser)](https://www.nuget.org/packages/DotNetColorParser/) -[![DotNetColorParser.Abstractions NuGet Package](https://img.shields.io/nuget/v/DotNetColorParser.Abstractions)](https://www.nuget.org/packages/DotNetColorParser.Abstractions/) ![Coverage](https://img.shields.io/azure-devops/coverage/robolynx/DotNetColorParser/6/main) .Net library parsing strings with notated colors and converting them to .Net Color object. Library support almost all color notations used in CSS3. Color notations are extendable and customizable. +### NuGet's + +[![DotNetColorParser NuGet Package](https://img.shields.io/nuget/v/DotNetColorParser?label=nuget:DotNetColorParser)](https://www.nuget.org/packages/DotNetColorParser/) + +[![DotNetColorParser.Abstractions NuGet Package](https://img.shields.io/nuget/v/DotNetColorParser.Abstractions?label=nuget:DotNetColorParser.Abstractions)](https://www.nuget.org/packages/DotNetColorParser.Abstractions/) + + ## Usage ### Static methods -#### Any color notation +#### Many color notations -You can use static method witch converts string with any correct color notation supported by default. e.g: +You can use static method witch converts string with any correct color notation supporting by default. e.g: ```c# string stringWithColor = "rgba(255,0,128,0.5)"; @@ -21,11 +26,11 @@ string stringWithColor = "rgba(255,0,128,0.5)"; var color = ColorParser.Parse(stringWithColor); ``` -In that case method try parse string using all notations added to `ColorParser.DefaultProvider` collection. This object by default contains all standard color notations. +In that case method parse string using all notations added to `ColorParser.DefaultProvider` collection. This object by default contains all build in color notations. #### Specify color notation only -If you wont to parser only one specify notation then you can write: +If you wont to parser support only one specify notation then you can write: ```c# string stringWithColor = "#ff008080"; @@ -42,12 +47,12 @@ You can add custom color notation support by adding to `ColorParser.DefaultProvi To customize supported by default color notations you can set to `ColorParser.DefaultProvider` new ColorNotationProvider class instance. ```c# -ColorParser.DefaultProvider = new ColorNotationProvider() { HexRGBANotation, RGBANotation, RGBNotation }; +ColorParser.DefaultProvider = new ColorNotationProvider() { HexRGBANotation, RGBANotation, RGBNotation, CustomNotation }; ``` ### Class instance -You can dynamically create new instance of ColorParser class and configure supported notations by passing ColorNotationProvider object into constructor. +You can dynamically create new instance of ColorParser class and configure supporting notations by passing ColorNotationProvider object into constructor. ```c# var colorParser = new ColorParser(new ColorNotationProvider() { HexRGBANotation, RGBANotation, RGBNotation }); @@ -102,14 +107,101 @@ All this notations are default added to ColorNotationProvider. | Class name | Description | Syntax | e.g. | | :------------------- | :----------- | ------------------- | :---- | -| KnownColorNameNotation | Color names in English containing by [KnownColor](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.knowncolor?view=net-5.0&viewFallbackFrom=netstandard-2.0) enumerable object. It's contains all color names using by browsers. Colors are in RGB color space. Every color corresponding specify RBG value. | `colorname` | `silver`, `blue`, `black`, `green`, `yellow`, `darkblue` | -| HexRGBANotation | RGB or RGBA color expressed through hexadecimal value with # prefix (prefix not necessary to correct recognition). Color can be expressed as three, six or eight hexadecimal characters (0–9, A–F). | `#RRGGBB[AA]`
`#RGB[A]` | `#FFFFFF`, `#abc`, `#20ee33`, `#ff1250cc` | -| RGBNotation | [RGB color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#rgb_colors)| **Syntax 1:** rgb(R, G, B)
**Syntax 2:** rgb R G B | `rgb(255,255,0)`, `rgb( 255, 255, 255 )` | -| RGBANotation | The same as RGBNotation but with additional alpha channel. | **Syntax 1:** rgba(R, G, B, A)
**Syntax 2:** rgba R G B A
**Syntax 3:** rgba R G B / A
**Syntax 4:** rgba(R G B / A) | `rgba(255,255,0,0.5)`, `rgba( 255, 255, 255, 100% )` | -| HSLNotation | [HSLA color space](https://en.wikipedia.org/wiki/HSL_and_HSV) | **Syntax 1:** `hsl(hue, spectrum, lightness)`
**Syntax 2:** `hsl hue, spectrum, lightness`
**Syntax 4:** `hsla(hue spectrum lightness)`

| `hsla(180,50%,50%,0.5)`, `hsla(180,50%,50%,30%)`, `hsla(180deg,50%,50%,30%)`, `hsla(4rad,50%,50%,30%)`, `hsla(4ang,50%,50%,30%)`,`hsla 180,50%,50%,0.5`, `hsla 180 50% 50% 0.5`, `hsla 180 50% 50% / 0.5` -| HSLANotation | The same as HSLNotation but with additional alpha channel. | **Syntax 1:** `hsla(hue, spectrum, lightness, alpha)`
**Syntax 2:** `hsla hue, spectrum, lightness / alpha`
**Syntax 3:** `hsla hue spectrum lightness alpha`
**Syntax 4:** `hsla(hue spectrum lightness alpha)` | `hsla(180,50%,50%,0.5)`, `hsla(180,50%,50%,30%)`, `hsla(180deg,50%,50%,30%)`, `hsla(4rad,50%,50%,30%)`, `hsla(4ang,50%,50%,30%)`,`hsla 180,50%,50%,0.5`, `hsla 180 50% 50% 0.5`, `hsla 180 50% 50% / 0.5` -| HSVNotation | [HSVA color space](https://en.wikipedia.org/wiki/HSL_and_HSV) | **Syntax 1:** `hsla(hue, spectrum, lightness, alpha)`
**Syntax 2:** `hsla hue, spectrum, lightness / alpha`
**Syntax 3:** `hsla hue spectrum lightness alpha`
**Syntax 4:** `hsla(hue spectrum lightness alpha)` | `hsla(180,50%,50%,0.5)`, `hsla(180,50%,50%,30%)`, `hsla(180deg,50%,50%,30%)`, `hsla(4rad,50%,50%,30%)`, `hsla(4ang,50%,50%,30%)`,`hsla 180,50%,50%,0.5`, `hsla 180 50% 50% 0.5`, `hsla 180 50% 50% / 0.5` - +### 1. **KnownColorNameNotation** +#### Description +Color names in English containing by [KnownColor](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.knowncolor?view=net-5.0&viewFallbackFrom=netstandard-2.0) enumerable object. It's contains all color names using by browsers. Colors are in RGB color space. Every color corresponding specify RBG value. +#### Syntax +`colorname` +#### Samples +* `silver` +* `blue` +* `black` +* `green` +* `yellow` +* `darkblue` +### 2. HexRGBANotation +#### Description +RGB or RGBA color expressed through hexadecimal value with # prefix (prefix not necessary to correct recognition). Color can be expressed as three, six or eight hexadecimal characters (0–9, A–F). +#### Syntax +1. `#RRGGBB[AA]` +1. `#RGB[A]` +#### Samples +* `#FFFFFF` +* `#abc` +* `#20ee33` +* `#ff1250cc` +### 3. RGBNotation +#### Description +[RGB color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#rgb_colors) +#### Syntax +1. rgb(R, G, B) +1. rgb R G B +#### Samples +* `rgb(255,255,0)` +* `rgb( 255, 255, 255 )` +### 4. RGBANotation +#### Description +The same as RGBNotation but with additional alpha channel. +#### Syntax +1. rgba(R, G, B, A) +1. rgba R G B A +1. rgba R G B / A +1. rgba(R G B / A) +#### Samples +* `rgba(255,255,0,0.5)` +* `rgba( 255, 255, 255, 100% )` +### 5. HSLNotation +#### Description +[HSLA color space](https://en.wikipedia.org/wiki/HSL_and_HSV) +#### Syntax +1. `hsl(hue, spectrum, lightness)` +2. `hsl hue, spectrum, lightness` +3. `hsla(hue spectrum lightness)` +#### Samples +* `hsla(180,50%,50%,0.5)` +* `hsla(180,50%,50%,30%)` +* `hsla(180deg,50%,50%,30%)` +* `hsla(4rad,50%,50%,30%)` +* `hsla(4ang,50%,50%,30%)` +* `hsla 180,50%,50%,0.5` +* `hsla 180 50% 50% 0.5` +* `hsla 180 50% 50% / 0.5` +### 6. HSLANotation +#### Description +The same as HSLNotation but with additional alpha channel. +#### Syntax +1. `hsla(hue, spectrum, lightness, alpha)` +1. `hsla hue, spectrum, lightness / alpha` +1. `hsla hue spectrum lightness alpha` +1. `hsla(hue spectrum lightness alpha)` +#### Samples +* `hsla(180,50%,50%,0.5)` +* `hsla(180,50%,50%,30%)` +* `hsla(180deg,50%,50%,30%)` +* `hsla(4rad,50%,50%,30%)` +* `hsla(4ang,50%,50%,30%)` +* `hsla 180,50%,50%,0.5` +* `hsla 180 50% 50% 0.5` +* `hsla 180 50% 50% / 0.5` +### 7. HSVNotation +#### Description +[HSVA color space](https://en.wikipedia.org/wiki/HSL_and_HSV) +#### Syntax +1. `hsla(hue, spectrum, lightness, alpha)` +2. `hsla hue, spectrum, lightness / alpha` +3. `hsla hue spectrum lightness alpha` +4. `hsla(hue spectrum lightness alpha)` +#### Syntax +* `hsla(180,50%,50%,0.5)` +* `hsla(180,50%,50%,30%)` +* `hsla(180deg,50%,50%,30%)` +* `hsla(4rad,50%,50%,30%)` +* `hsla(4ang,50%,50%,30%)` +* `hsla 180,50%,50%,0.5` +* `hsla 180 50% 50% 0.5` +* `hsla 180 50% 50% / 0.5` + +------------- **R** (red), **G** (green), **B** (blue) - number between 0 and 255. **A** - decimal number between 0 and 1 or percentage value between 0% and 100%