From 1cf2a3a0f005877c25f7eb09c1cb57383552f447 Mon Sep 17 00:00:00 2001 From: DarthAffe Date: Wed, 2 Dec 2015 12:20:52 +0100 Subject: [PATCH] Added some content --- Implementing-an-own-brush.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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