diff --git a/Implementing-an-own-brush.md b/Implementing-an-own-brush.md index 30404ce..f2f4e84 100644 --- a/Implementing-an-own-brush.md +++ b/Implementing-an-own-brush.md @@ -1 +1,20 @@ -TODO \ No newline at end of file +Implementing an own brush is quite easy. +All you need to do is implementing the _IBrush_-interface which looks like this: +```C# +public interface IBrush +{ + float Brightness { get; set; } + float Opacity { get; set; } + Color GetColorAtPoint(RectangleF rectangle, PointF point); +} +``` + +> **Since the _Brightness_ and _Opacity_ is something generic you should always derive from the [_AbstractBrush_-](https://github.com/DarthAffe/CUE.NET/blob/master/Brushes/AbstractBrush.cs)Class.** +> If you do this, you'll only have to implement the _GetColorAtPoint_-method. + +In the _GetColorAtPoint_-method you'll have to calculate and return the color of one specific point (representing a key) inside a rectangle (representing the keyboard or keygroup). Both, the point and the rectangle are given as parameters. + +> Before you return your calculated Color you should always call the _FinalizeColor_-method to apply the overall brightness and opacity. +> If you don't derive from the _AbstractBrush_-Class you'll have to to take care about this by yourself. + +If you need a reference on how the implementation might look, you can take the [_LinearGradientBrush_](https://github.com/DarthAffe/CUE.NET/blob/master/Brushes/LinearGradientBrush.cs), the [_RadialGradientBrush_](https://github.com/DarthAffe/CUE.NET/blob/master/Brushes/RadialGradientBrush.cs) or the [_SolidColorBrush_](https://github.com/DarthAffe/CUE.NET/blob/master/Brushes/SolidColorBrush.cs). \ No newline at end of file