1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Updated Brushes (markdown)

Robert Beekman 2016-11-02 00:15:19 +01:00
parent e9d9bd7bc6
commit 53c394238b

@ -1,15 +1,84 @@
The Brushes variable lets you create colors and apply them to brushes
The Brushes variable lets you create colors and apply them to different kinds of brushes.
For more info on how brushes are drawn, check out [WPF LinearGradientBrush](http://www.c-sharpcorner.com/uploadfile/mahesh/wpf-radialgradientbrush/) and [WPF RadialGradientBrush](http://www.c-sharpcorner.com/uploadfile/mahesh/wpf-lineargradientbrush/) or have a look at the LUA examples.
**Note:** To actually draw the brushes, see the [Drawing](https://github.com/SpoinkyNL/Artemis/wiki/Drawing) section.
## Properties
## Functions
### GetColor
Turns the provided hex notation into a color
Creates a color using the given variables.
You may either provide a hex notation: ```#0066ff``` or an ARGB notation: ```255, 255, 0, 0```
#### Syntax:
```lua
color GetColor(string hexCode);
color GetColor(int a, int r, int g, int b);
```
#### Example:
```lua
local color = Brushes.GetColor("#ffffff");
```
local blueColor = Brushes.GetColor("#0066ff");
local redColor = Brushes.GetColor(255, 255, 0, 0);
```
### GetRandomColor
Returns a psuedo-random color within the RGB spectrum.
#### Syntax:
```lua
color GetRandomColor();
```
#### Example:
```lua
local randomColor = Brushes.GetRandomColor();
```
### GetSolidColorBrush()
Returns a brush with one color
#### Syntax:
```lua
brush GetSolidColorBrush(color brushColor);
```
#### Example:
```lua
-- Create a red color
local redColor = Brushes.GetColor(255, 255, 0, 0);
-- Create the brush using the newly created color
local redBrush = Brushes.GetSolidColorBrush(redColor);
```
#### Result:
Drawing the first brush would look like this:
![SolidColorBrush](http://i.imgur.com/NDT1lD2.png "SolidColorBrush")
### GetLinearGradientBrush()
Returns a brush with a linear gradient
#### Syntax:
```lua
brush GetSolidColorBrush(table gradientColors, [double startX, double startY, double endX, double endY]);
```
##### Required arguments
- **gradientColors:** A table using colors as keys and doubles as offsets
##### Optional arguments
**Note:** The arguments between [brackets] are optional and you can leave them out.
- **startX:** The X value of the start position of the gradient
- **startY:** The Y value of the start position of the gradient
- **endX:** The X value of the end position of the gradient
- **endY:** The Y value of the end position of the gradient
#### Example:
```lua
-- Create a table and in that table add tables containing a color and an offset
local colors = {};
colors[Brushes.GetColor(255, 255, 0, 0)] = 0; -- red
colors[Brushes.GetColor(255, 255, 0, 255)] = 0.16; -- purple
colors[Brushes.GetColor(255, 0, 0, 255)] = 0.33; -- blue
colors[Brushes.GetColor(255, 0, 255, 255)] = 0.5; -- cyan
colors[Brushes.GetColor(255, 0, 255, 0)] = 0.66; -- green
colors[Brushes.GetColor(255, 255, 255, 0)] = 0.83; -- yellow
colors[Brushes.GetColor(255, 255, 0, 0)] = 1; -- red
-- Create the brush using the newly created color
local rainbowBrush = Brushes.GetLinearGradientBrush(colors);
-- Create another brush using the optional arguments
local horizontalBrush = Brushes.GetLinearGradientBrush(colors, 0, 0.5, 1, 0.5);
```
#### Result:
Drawing the first brush would look like this:
![LinearGradientBrush](http://i.imgur.com/VRgpFW0.png "LinearGradientBrush")
Drawing the second brush would look like this:
![LinearGradientBrush](http://i.imgur.com/EH5ITup.png "LinearGradientBrush")