From c7bd81a47ec2d9a700cd55db68f3e18d95c6a346 Mon Sep 17 00:00:00 2001 From: DarthAffe Date: Sat, 14 Nov 2015 16:22:57 +0100 Subject: [PATCH] Added some content --- Implementing-an-own-gradient.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Implementing-an-own-gradient.md b/Implementing-an-own-gradient.md index 30404ce..f914a7a 100644 --- a/Implementing-an-own-gradient.md +++ b/Implementing-an-own-gradient.md @@ -1 +1,16 @@ -TODO \ No newline at end of file +Implementing an own gradient is quite easy. +All you need to do is implementing the _IGradient_-interface which looks like this: +```C# +public interface IGradient +{ + Color GetColor(float offset); +} +``` + +Just place your calculation-logic inside the _GetColor_-Method and return the Color for the requested offset. (The offset represents the percentage value of "progress" on the gradient.) +Even if it might not be needed please handle the case of a negative offset or values greater 1! +> Before you start take a look at the helper-methods in the _[ColorHelper](https://github.com/DarthAffe/CUE.NET/blob/master/Helper/ColorHelper.cs)_- and _[GradientHelper](https://github.com/DarthAffe/CUE.NET/blob/master/Helper/GradientHelper.cs)_-classes. They might be useful! + +If you want to work with _GradientStops_ (like the _[LinearGradient](https://github.com/DarthAffe/CUE.NET/wiki/Linear-Gradient)_) you can derive from the _[AbstractGradient](https://github.com/DarthAffe/CUE.NET/blob/master/Gradients/AbstractGradient.cs)_-class which implements some logic helping with that. + +If you need a reference on how the implementation might look you can take the _[LinearGradient](https://github.com/DarthAffe/CUE.NET/blob/master/Gradients/LinearGradient.cs)_ or the _[RainbowGradient](https://github.com/DarthAffe/CUE.NET/blob/master/Gradients/RainbowGradient.cs)_. \ No newline at end of file