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

Updated Drawing (markdown)

Robert Beekman 2016-11-03 17:40:04 +01:00
parent 7d2ab953c4
commit 1f5f70e6cb

@ -1,13 +1,135 @@
The Drawing event lets you draw shapes to the keyboard. Drawing can only be done within the ProfileDrawing event.
The Drawing variable lets you draw brushes to the keyboard in different shapes.
To get the Drawing variable you need to subscribe to the [ProfileDrawing](https://github.com/SpoinkyNL/Artemis/wiki/LUA-Events#profiledrawing) event, as shown in the examples paired with each funtion.
## Overview
* [DrawEllipse](https://github.com/SpoinkyNL/Artemis/wiki/brushes#getcolor)
* [DrawLine](https://github.com/SpoinkyNL/Artemis/wiki/brushes#getrandomcolor)
* [DrawRectangle](https://github.com/SpoinkyNL/Artemis/wiki/brushes#getsolidcolorbrush)
* [DrawText](https://github.com/SpoinkyNL/Artemis/wiki/brushes#getlineargradientbrush)
## Functions
### TODO
Desc TODO
### DrawEllipse
Draws an ellipse on the keyboard.
#### Syntax:
```lua
--Syntax TODO
DrawEllipse(brush brush, double x, double y, double height, double width);
```
##### Required arguments
- **brush:** A [brush](https://github.com/SpoinkyNL/Artemis/wiki/brushes) used to fill the ellipse
- **x:** The X-position of the ellipse, from the top-left
- **y:** The Y-position of the ellipse, from the top-left
- **height:** The width of the ellipse
- **width:** The height of the ellipse
#### Example:
```lua
--Example TODO
```
-- Create a brush we want to draw to the keyboard at a later time
local redBrush = Brushes.GetSolidColorBrush(Brushes.GetColor(255, 255, 0, 0));
-- This function will be called after every profile draw.
function drawHandler(profile, eventArgs)
-- Draw an ellipse (in this case a circle) in the top left
eventArgs.Drawing.DrawEllipse(redBrush, 0, 0, 5, 5);
end
-- Subscribe to the event AFTER defining the function which must be subscribed.
Events.ProfileDrawing.add(drawHandler);
```
#### Result:
Pretent there's an image here..
---
### DrawLine
Draws a line on the keyboard.
#### Syntax:
```lua
DrawLine(brush brush, double startX, double startY, double endX, double endY, double thickness);
```
##### Required arguments
- **brush:** A [brush](https://github.com/SpoinkyNL/Artemis/wiki/brushes) used to fill the line
- **startX:** The X-position of the starting point of the line
- **startY:** The Y-position of the starting point of the line
- **endX:** The X-position of the end point of the line
- **endY:** The Y-position of the end point of the line
#### Example:
```lua
-- Create a brush we want to draw to the keyboard at a later time
local redBrush = Brushes.GetSolidColorBrush(Brushes.GetColor(255, 255, 0, 0));
-- This function will be called after every profile draw.
function drawHandler(profile, eventArgs)
-- Draw a line from the top left to the bottom left
eventArgs.Drawing.DrawLine(redBrush, 0, 0, 5, 5);
end
-- Subscribe to the event AFTER defining the function which must be subscribed.
Events.ProfileDrawing.add(drawHandler);
```
#### Result:
Pretent there's an image here..
---
### DrawRectangle
Draws an rectangle on the keyboard.
#### Syntax:
```lua
DrawRectangle(brush brush, double x, double y, double height, double width);
```
##### Required arguments
- **brush:** A [brush](https://github.com/SpoinkyNL/Artemis/wiki/brushes) used to fill the rectangle
- **x:** The X-position of the rectangle, from the top-left
- **y:** The Y-position of the rectangle, from the top-left
- **height:** The width of the rectangle
- **width:** The height of the rectangle
#### Example:
```lua
-- Create a brush we want to draw to the keyboard at a later time
local redBrush = Brushes.GetSolidColorBrush(Brushes.GetColor(255, 255, 0, 0));
-- This function will be called after every profile draw.
function drawHandler(profile, eventArgs)
-- Draw an rectangle (in this case a square) in the top left
eventArgs.Drawing.DrawRectangle(redBrush, 0, 0, 5, 5);
end
-- Subscribe to the event AFTER defining the function which must be subscribed.
Events.ProfileDrawing.add(drawHandler);
```
#### Result:
Pretent there's an image here..
---
### DrawText
Draws a text string on the keyboard.
**Note:** Drawing text to the keyboard has very little practical use. Since the keys aren't aligned in a grid it's not very readable. The main reason I've included this function is so that you can use it to draw symbols, such as ```<```, ```>```, ```^``` etc.
#### Syntax:
```lua
DrawText(brush brush, double x, double y, string text, int fontSize);
```
##### Required arguments
- **brush:** A [brush](https://github.com/SpoinkyNL/Artemis/wiki/brushes) used to fill the rectangle
- **x:** The X-position of the text, from the top-left
- **y:** The Y-position of the text, from the top-left
- **text:** The text to draw
- **fontSize:** The font size of the text to draw.
**Note:** As you can see in the example, for the best result I use a fontsize of 11, using the entire keyboard's height (on a K95 at least).
To compensate for the margin the font has on the top I'm using a Y-value of -2.4.
#### Example:
```lua
-- Create a brush we want to draw to the keyboard at a later time
local redBrush = Brushes.GetSolidColorBrush(Brushes.GetColor(255, 255, 0, 0));
-- This function will be called after every profile draw.
function drawHandler(profile, eventArgs)
-- Draw the text "hi" on the keyboard.
eventArgs.Drawing.DrawText(redBrush, 4, -2.4, "hi", 11);
end
-- Subscribe to the event AFTER defining the function which must be subscribed.
Events.ProfileDrawing.add(drawHandler);
```
#### Result:
Pretent there's an image here..