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

Updated Drawing (markdown)

Robert Beekman 2017-09-12 14:18:58 +02:00
parent ea5b78a015
commit 2a4c945e96

@ -12,7 +12,7 @@ To get the Drawing variable you need to subscribe to the [DeviceDrawing](https:/
Draws an ellipse on the keyboard.
#### Syntax:
```lua
DrawEllipse(brush brush, double x, double y, double height, double width);
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
@ -24,16 +24,16 @@ DrawEllipse(brush brush, double x, double y, double height, double width);
#### 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));
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);
-- 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.DeviceDrawing.add(drawHandler);
Events.DeviceDrawing.add(drawHandler)
```
#### Result:
Drawing the ellipse would look like this:
@ -44,7 +44,7 @@ Drawing the ellipse would look like this:
Draws a line on the keyboard.
#### Syntax:
```lua
DrawLine(brush brush, double startX, double startY, double endX, double endY, double thickness);
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
@ -57,16 +57,16 @@ DrawLine(brush brush, double startX, double startY, double endX, double endY, do
#### 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));
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, 1);
-- Draw a line from the top left to the bottom left
eventArgs.Drawing.DrawLine(redBrush, 0, 0, 5, 5, 1)
end
-- Subscribe to the event AFTER defining the function which must be subscribed.
Events.DeviceDrawing.add(drawHandler);
Events.DeviceDrawing.add(drawHandler)
```
#### Result:
Drawing the line would look like this:
@ -77,7 +77,7 @@ Drawing the line would look like this:
Draws an rectangle on the keyboard.
#### Syntax:
```lua
DrawRectangle(brush brush, double x, double y, double height, double width);
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
@ -89,16 +89,16 @@ DrawRectangle(brush brush, double x, double y, double height, double width);
#### 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));
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);
-- 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.DeviceDrawing.add(drawHandler);
Events.DeviceDrawing.add(drawHandler)
```
#### Result:
Drawing the rectangle would look like this:
@ -110,7 +110,7 @@ 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);
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
@ -124,16 +124,21 @@ 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));
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);
-- In this example we only want to draw to the keyboard. Each device has it's
-- own drawing event
if not (eventArgs.DeviceType == "keyboard") then
return
end
-- 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.DeviceDrawing.add(drawHandler);
Events.DeviceDrawing.add(drawHandler)
```
#### Result:
Drawing the text would look like this: