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 12:05:55 +01:00
parent 97e54d006a
commit ab8c87143b

@ -1,24 +1,31 @@
The Brushes variable lets you create colors and apply them to different kinds of 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. For more info on how brushes are drawn, check out [WPF LinearGradientBrush](http://www.c-sharpcorner.com/uploadfile/mahesh/wpf-lineargradientbrush/) and [WPF RadialGradientBrush](http://www.c-sharpcorner.com/uploadfile/mahesh/wpf-radialgradientbrush/) 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. **Note:** To actually draw the brushes, see the [Drawing](https://github.com/SpoinkyNL/Artemis/wiki/Drawing) section.
## Properties
## Functions ## Functions
### GetColor ### GetColor
Creates a color using the given variables. Creates a color using the given variables.
You may either provide a hex notation: ```#0066ff``` or an ARGB notation: ```255, 255, 0, 0```
#### Syntax: #### Syntax:
```lua ```lua
color GetColor(string hexCode); color GetColor(string hexCode);
color GetColor(int a, int r, int g, int b); color GetColor(int a, int r, int g, int b);
``` ```
##### Required arguments
- **hexCode:** A hex color notation, such as ```#0066ff```
##### Alternative arguments
- **a:** A byte alpha value (0-255)
- **r:** A byte red value (0-255)
- **g:** A byte green value (0-255)
- **b:** A byte blue value (0-255)
#### Example: #### Example:
```lua ```lua
local blueColor = Brushes.GetColor("#0066ff"); local blueColor = Brushes.GetColor("#0066ff");
local redColor = Brushes.GetColor(255, 255, 0, 0); local redColor = Brushes.GetColor(255, 255, 0, 0);
``` ```
---
### GetRandomColor ### GetRandomColor
Returns a psuedo-random color within the RGB spectrum. Returns a psuedo-random color within the RGB spectrum.
#### Syntax: #### Syntax:
@ -29,12 +36,16 @@ color GetRandomColor();
```lua ```lua
local randomColor = Brushes.GetRandomColor(); local randomColor = Brushes.GetRandomColor();
``` ```
### GetSolidColorBrush() ---
### GetSolidColorBrush
Returns a brush with one color Returns a brush with one color
#### Syntax: #### Syntax:
```lua ```lua
brush GetSolidColorBrush(color brushColor); brush GetSolidColorBrush(color brushColor);
``` ```
##### Required arguments
- **color:** The color the brush will be
#### Example: #### Example:
```lua ```lua
-- Create a red color -- Create a red color
@ -45,8 +56,8 @@ local redBrush = Brushes.GetSolidColorBrush(redColor);
#### Result: #### Result:
Drawing the first brush would look like this: Drawing the first brush would look like this:
![SolidColorBrush](http://i.imgur.com/NDT1lD2.png "SolidColorBrush") ![SolidColorBrush](http://i.imgur.com/NDT1lD2.png "SolidColorBrush")
---
### GetLinearGradientBrush() ### GetLinearGradientBrush
Returns a brush with a linear gradient Returns a brush with a linear gradient
#### Syntax: #### Syntax:
```lua ```lua
@ -57,10 +68,11 @@ brush GetSolidColorBrush(table gradientColors, [double startX, double startY, do
##### Optional arguments ##### Optional arguments
**Note:** The arguments between [brackets] are optional and you can leave them out. **Note:** The arguments between [brackets] are optional and you can leave them out.
- **startX:** The X value of the start position of the gradient - **startX:** The relative X value of the start position of the gradient
- **startY:** The Y value of the start position of the gradient - **startY:** The relative Y value of the start position of the gradient
- **endX:** The X value of the end position of the gradient - **endX:** The relative X value of the end position of the gradient
- **endY:** The Y value of the end position of the gradient - **endY:** The relative Y value of the end position of the gradient
#### Example: #### Example:
```lua ```lua
-- Create a table and add keys to it (the color) and values (the offset). -- Create a table and add keys to it (the color) and values (the offset).
@ -82,4 +94,43 @@ local horizontalBrush = Brushes.GetLinearGradientBrush(colors, 0, 0.5, 1, 0.5);
Drawing the first brush would look like this: Drawing the first brush would look like this:
![LinearGradientBrush](http://i.imgur.com/VRgpFW0.png "LinearGradientBrush") ![LinearGradientBrush](http://i.imgur.com/VRgpFW0.png "LinearGradientBrush")
Drawing the second brush would look like this: Drawing the second brush would look like this:
![LinearGradientBrush](http://i.imgur.com/EH5ITup.png "LinearGradientBrush") ![LinearGradientBrush](http://i.imgur.com/EH5ITup.png "LinearGradientBrush")
---
### GetRadialGradientBrush
Returns a brush with a radial gradient
#### Syntax:
```lua
brush GetSolidColorBrush(table gradientColors, [double centerX, double centerY, double originX, double originY]);
```
##### 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.
- **centerX:** The relative X value of the center position of the gradient
- **centerY:** The relative Y value of the center position of the gradient
- **originX:** The relative X value of the origin position of the gradient
- **originY:** The relative Y value of the origin position of the gradient
#### 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, 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 circle = Brushes.GetRadialGradientBrush(colors);
-- Create another brush putting the origin in the top left (0,0) resulting in a spotlight
local spotlight = Brushes.GetRadialGradientBrush(colors, 0.5, 0.5, 0, 0);
```
#### Result:
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")