Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nor0x/maui.colorpicker
a color picker control for .NET MAUI powered by SkiaSharp.
https://github.com/nor0x/maui.colorpicker
color-picker colorpicker dotnet maui skiasharp
Last synced: 20 days ago
JSON representation
a color picker control for .NET MAUI powered by SkiaSharp.
- Host: GitHub
- URL: https://github.com/nor0x/maui.colorpicker
- Owner: nor0x
- License: mit
- Created: 2022-08-22T12:08:41.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-21T13:13:07.000Z (26 days ago)
- Last Synced: 2024-10-21T20:59:40.225Z (25 days ago)
- Topics: color-picker, colorpicker, dotnet, maui, skiasharp
- Language: C#
- Homepage: https://johnnys.news/2022/08/say-hello-to-Maui-ColorPicker
- Size: 229 KB
- Stars: 57
- Watchers: 4
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Maui.ColorPicker 🎨
a color picker control for .NET MAUI powered by SkiaSharp.[![.NET](https://github.com/nor0x/Maui.ColorPicker/actions/workflows/dotnet.yml/badge.svg)](https://github.com/nor0x/Maui.ColorPicker/actions/workflows/dotnet.yml)
[![](https://img.shields.io/nuget/v/nor0x.Maui.ColorPicker)](https://www.nuget.org/packages/nor0x.Maui.ColorPicker)
[![](https://img.shields.io/nuget/dt/nor0x.Maui.ColorPicker)](https://www.nuget.org/packages/nor0x.Maui.ColorPicker)this is largely based on `XFColorPickerControl` for Xamarin.Forms (https://github.com/UdaraAlwis/XFColorPickerControl) by [UdaraAlwis](https://github.com/UdaraAlwis) who allowed me to publish this updated version of the control 🙌
## Getting Started
initialize SkiaSharp in your app by calling the `UseSkiaSharp` method on the `MauiAppBuilder`
```csharp
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp()
.UseSkiaSharp()
...
```
add namespace
```xml
xmlns:controls="clr-namespace:Maui.ColorPicker;assembly=Maui.ColorPicker"
```
create control
```xml```
## Bindable Properties
### ```ColorPicked```:
Gets or sets the Picked Color of the Color Picker.XAML:
```xml```
C#:
```csharp
var colorPicked = ColorPicker.ColorPicked;
```### ```BaseColorList```:
Change the available base Colors on the Color Spectrum, of the Color Picker. This will take a **List of strings included with Color names or hex values** which is held in an IEnumerable.
#### XML:
```xml
#ffff00
#00ffff
#ff00ff
#ffff00
```
#### C#:
```csharp
ColorPicker.BaseColorList = new List()
{
"#00bfff",
"#0040ff",
"#8000ff",
"#ff00ff",
"#ff0000",
};
```### ```ColorFlowDirection```:
Change the direction in which the Colors are flowing through on the Color Spectrum, of the Color Picker. This will allow you to set whether the Colors are flowing through from left to right, **Horizontally** or top to bottom, **Vertically**#### XAML
```xml```
#### C#:
```csharp
ColorPicker.ColorFlowDirection =
Udara.Plugin.controls.ColorFlowDirection.Horizontal;
```### ```ColorSpectrumStyle```:
Change the Color Spectrum gradient style, with the rendering combination of base colors (**Hue**), or lighter colors (**Tint**) or darker colors (**Shade**).
Available Styles:
- HueOnlyStyle
- HueToShadeStyle
- ShadeToHueStyle
- HueToTintStyle
- TintToHueStyle
- TintToHueToShadeStyle
- ShadeToHueToTintStyle#### XML:
```xml```
#### C#:
```csharp
ColorPicker.ColorSpectrumStyle =
Udara.Plugin.controls.ColorSpectrumStyle.TintToHueToShadeStyle;
```### ```PointerRingDiameterUnits```:
Changes the Diameter size of the Pointer Ring on the Color Picker. It accepts values between 0 and 1, as a representation of numerical units which is compared to the 1/10th of the longest length of the Color Picker Canvas. By default this value is set to 0.6 units.
#### XML:
```xml```
#### C#:
```csharp
ColorPicker.PointerRingDiameterUnits = 0.6;
```### ```PointerRingBorderUnits```:
Changes the Border Thickness size of the Pointer Ring on the Color Picker. It accepts values between 0 and 1, as a representation of numerical units which is calculated against the diameter of the Pointer Ring. By default this value is set to 0.3 units.
#### XML:
```xml```
#### C#:
```csharp
ColorPicker.PointerRingBorderUnits = 0.3;
```### ```PointerRingPositionUnits```:
Changes the Pointer Ring’s position on the Color Picker Canvas programmatically. There are of two bindable properties **PointerRingPositionXUnits** and **PointerRingPositionYUnits**, which represents X and Y coordinates on the Color Picker Canvas. It accepts values between 0 and 1, as a presentation of numerical units which is calculated against the Color Picker Canvas’s actual pixel Width and Height. By default both the values are set to 0.5 units, which positions the Pointer Ring in the center of the Color Picker.
#### XML:
```xml```
#### C#:
```csharp
ColorPicker.PointerRingPositionXUnits = 0.3;
ColorPicker.PointerRingPositionYUnits = 0.7;
```## Event Handler
Fires every time when the selected Color is changed
### ```PickedColorChanged```:
Gets the pickedColor, object type of Color```xml
```
#### C#:
```csharp
ColorPicker.PickedColorChanged += ColorPicker_PickedColorChanged;
```
```csharp
private void ColorPicker_PickedColorChanged(object sender, Color colorPicked)
{
//Do whatever you want with the colorPicker
}
```## Customization
since the control is just a `ContentView` it can be customized in many ways - this is an example of a `Clip` applied to the color picker.https://user-images.githubusercontent.com/3210391/190870180-a7851bc4-c0f1-4b60-8212-b9668aebe091.mp4
⬇️ Xamarin.Forms Version README.md ⬇️
Color Picker Control for Xamarin.Forms!
===========Interactive and responsive Color Picker Control for Xamarin.Forms (Android, iOS, UWP) with a whole bunch of awesome features. On a Canvas with a beautiful Color spectrum similar to a rainbow gradient effect spreading across, drag, drop, swipe and pan over the Canvas to pick the Color you need easily, in a fun-to-use interactive experience. Built from pure Xamarin.Forms based on SkiaSharp, lightweight and fast!
Setting it up:
* Grab it on NuGet: https://www.nuget.org/packages/Udara.Plugin.XFColorPickerControl/ [![NuGet](https://img.shields.io/nuget/v/Udara.Plugin.XFColorPickerControl.svg?label=NuGet)](https://www.nuget.org/packages/Udara.Plugin.XFColorPickerControl/)
* Just install in your Xamarin.Forms PCL/.NET Standard project, you're good to go!Blog post:
https://theconfuzedsourcecode.wordpress.com/2020/03/17/publishing-the-nuget-of-my-color-picker-control-for-xamarin-forms/## XAML Set up
```xml
xmlns:xfsegmentedcontrol="clr-namespace:Udara.Plugin.XFColorPickerControl;assembly=Udara.Plugin.XFColorPickerControl"
``````xml
#ff0000
#ffff00
#00ff00
#00ffff
#0000ff
#ff00ff
#ff0000
```
## PickedColorChanged Event
```csharp
private void ColorPicker_PickedColorChanged(object sender, Color colorPicked)
{
// do whatever you want with the colorPicked value
}
```## Bindable Properties
### ```ColorPicked```:
Gets the Picked Color of the Color Picker.XAML:
```xml```
C#:
```csharp
var colorPicked = ColorPicker.ColorPicked;
```### ```BaseColorList```:
Change the available base Colors on the Color Spectrum, of the Color Picker. This will take a **List of strings included with Color names or hex values** which is held in an IEnumerable.
#### XML:
```xml
#ffff00
#00ffff
#ff00ff
#ffff00
```
#### C#:
```csharp
ColorPicker.BaseColorList = new List()
{
"#00bfff",
"#0040ff",
"#8000ff",
"#ff00ff",
"#ff0000",
};
```### ```ColorFlowDirection```:
Change the direction in which the Colors are flowing through on the Color Spectrum, of the Color Picker. This will allow you to set whether the Colors are flowing through from left to right, **Horizontally** or top to bottom, **Vertically**#### XAML
```xml```
#### C#:
```csharp
ColorPicker.ColorFlowDirection =
Udara.Plugin.XFColorPickerControl.ColorFlowDirection.Horizontal;
```### ```ColorSpectrumStyle```:
Change the Color Spectrum gradient style, with the rendering combination of base colors (**Hue**), or lighter colors (**Tint**) or darker colors (**Shade**).
Available Styles:
- HueOnlyStyle
- HueToShadeStyle
- ShadeToHueStyle
- HueToTintStyle
- TintToHueStyle
- TintToHueToShadeStyle
- ShadeToHueToTintStyle#### XML:
```xml```
#### C#:
```csharp
ColorPicker.ColorSpectrumStyle =
Udara.Plugin.XFColorPickerControl.ColorSpectrumStyle.TintToHueToShadeStyle;
```### ```PointerRingDiameterUnits```:
Changes the Diameter size of the Pointer Ring on the Color Picker. It accepts values between 0 and 1, as a representation of numerical units which is compared to the 1/10th of the longest length of the Color Picker Canvas. By default this value is set to 0.6 units.
#### XML:
```xml```
#### C#:
```csharp
ColorPicker.PointerRingDiameterUnits = 0.6;
```### ```PointerRingBorderUnits```:
Changes the Border Thickness size of the Pointer Ring on the Color Picker. It accepts values between 0 and 1, as a representation of numerical units which is calculated against the diameter of the Pointer Ring. By default this value is set to 0.3 units.
#### XML:
```xml```
#### C#:
```csharp
ColorPicker.PointerRingBorderUnits = 0.3;
```### ```PointerRingPositionUnits```:
Changes the Pointer Ring’s position on the Color Picker Canvas programmatically. There are of two bindable properties **PointerRingPositionXUnits** and **PointerRingPositionYUnits**, which represents X and Y coordinates on the Color Picker Canvas. It accepts values between 0 and 1, as a presentation of numerical units which is calculated against the Color Picker Canvas’s actual pixel Width and Height. By default both the values are set to 0.5 units, which positions the Pointer Ring in the center of the Color Picker.
#### XML:
```xml```
#### C#:
```csharp
ColorPicker.PointerRingPositionXUnits = 0.3;
ColorPicker.PointerRingPositionYUnits = 0.7;
```## Event Handler
Fires every time when the selected Color is changed
### ```PickedColorChanged```:
Gets the pickedColor, object type of Color```xml
```
#### C#:
```csharp
ColorPicker.PickedColorChanged += ColorPicker_PickedColorChanged;
```
```csharp
private void ColorPicker_PickedColorChanged(object sender, Color colorPicked)
{
//Do whatever you want with the colorPicker
}
```