diff --git a/Brushes.md b/Brushes.md index 4148f82..a0ee397 100644 --- a/Brushes.md +++ b/Brushes.md @@ -6,10 +6,10 @@ For more info on how brushes are drawn, check out [WPF LinearGradientBrush](http ## Overview * [GetColor](https://github.com/SpoinkyNL/Artemis/wiki/brushes#getcolor) * [GetRandomColor](https://github.com/SpoinkyNL/Artemis/wiki/brushes#getrandomcolor) +* [GetRelativeColor](https://github.com/SpoinkyNL/Artemis/wiki/Brushes#getrelativecolor) * [GetSolidColorBrush](https://github.com/SpoinkyNL/Artemis/wiki/brushes#getsolidcolorbrush) * [GetLinearGradientBrush](https://github.com/SpoinkyNL/Artemis/wiki/brushes#getlineargradientbrush) * [GetRadialGradientBrush](https://github.com/SpoinkyNL/Artemis/wiki/brushes#getradialgradientbrush) -* [GetRelativeColor](https://github.com/SpoinkyNL/Artemis/wiki/Brushes#getrelativecolor) ## Functions ### GetColor @@ -44,6 +44,32 @@ color GetRandomColor(); ```lua local randomColor = Brushes.GetRandomColor(); ``` +--- +### GetRelativeColor +Returns the color at the given position in a gradient. +#### Syntax: +```lua +color GetRelativeColor(table gradientColors, double position); +``` +##### Required arguments +- **gradientColors:** A table using colors as keys and doubles as offsets +- **position:** A position between 0 and 1. + +#### Example: +```lua +-- Create a table and add keys to it (the color) and values (the offset). +local colors = {}; +colors[Brushes.GetColor(255, 255, 0, 0)] = 0; -- red +colors[Brushes.GetColor(255, 255, 255, 0)] = 1; -- yellow + +-- Get the color that is in the middle of the gradient, between red and yellow +local orange = Brushes.GetRelativeColor(colors, 0.5); +``` + +#### Result: +The function will look at the color in the middle, at 0.5 and it is orange +![Imgur](http://i.imgur.com/GbDIAQb.png) + --- ### GetSolidColorBrush Returns a brush with one color @@ -143,26 +169,4 @@ local spotlight = Brushes.GetRadialGradientBrush(colors, 0.5, 0.5, 0, 0); Drawing the first brush would look like this: ![RadialGradientBrush](http://i.imgur.com/GXkooQt.png "RadialGradientBrush") Drawing the second brush would look like this: -![RadialGradientBrush](http://i.imgur.com/PpMjgnq.png "RadialGradientBrush") - ---- -### GetRelativeColor -Returns the color at the given position in a gradient. -#### Syntax: -```lua -color GetRelativeColor(table gradientColors, double position); -``` -##### Required arguments -- **gradientColors:** A table using colors as keys and doubles as offsets -- **position:** A position between 0 and 1. - -#### Example: -```lua --- Create a table and add keys to it (the color) and values (the offset). -local colors = {}; -colors[Brushes.GetColor(255, 255, 0, 0)] = 0; -- red -colors[Brushes.GetColor(255, 255, 255, 0)] = 1; -- yellow - --- Get the color that is in the middle of the gradient, between red and yellow -local orange = Brushes.GetRelativeColor(colors, 0.5); -``` +![RadialGradientBrush](http://i.imgur.com/PpMjgnq.png "RadialGradientBrush") \ No newline at end of file