mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-01 18:23:32 +00:00
Updated Drawing (markdown)
parent
ea5b78a015
commit
2a4c945e96
45
Drawing.md
45
Drawing.md
@ -12,7 +12,7 @@ To get the Drawing variable you need to subscribe to the [DeviceDrawing](https:/
|
|||||||
Draws an ellipse on the keyboard.
|
Draws an ellipse on the keyboard.
|
||||||
#### Syntax:
|
#### Syntax:
|
||||||
```lua
|
```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
|
##### Required arguments
|
||||||
- **brush:** A [brush](https://github.com/SpoinkyNL/Artemis/wiki/brushes) used to fill the ellipse
|
- **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:
|
#### Example:
|
||||||
```lua
|
```lua
|
||||||
-- Create a brush we want to draw to the keyboard at a later time
|
-- 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.
|
-- This function will be called after every profile draw.
|
||||||
function drawHandler(profile, eventArgs)
|
function drawHandler(profile, eventArgs)
|
||||||
-- Draw an ellipse (in this case a circle) in the top left
|
-- Draw an ellipse (in this case a circle) in the top left
|
||||||
eventArgs.Drawing.DrawEllipse(redBrush, 0, 0, 5, 5);
|
eventArgs.Drawing.DrawEllipse(redBrush, 0, 0, 5, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
||||||
Events.DeviceDrawing.add(drawHandler);
|
Events.DeviceDrawing.add(drawHandler)
|
||||||
```
|
```
|
||||||
#### Result:
|
#### Result:
|
||||||
Drawing the ellipse would look like this:
|
Drawing the ellipse would look like this:
|
||||||
@ -44,7 +44,7 @@ Drawing the ellipse would look like this:
|
|||||||
Draws a line on the keyboard.
|
Draws a line on the keyboard.
|
||||||
#### Syntax:
|
#### Syntax:
|
||||||
```lua
|
```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
|
##### Required arguments
|
||||||
- **brush:** A [brush](https://github.com/SpoinkyNL/Artemis/wiki/brushes) used to fill the line
|
- **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:
|
#### Example:
|
||||||
```lua
|
```lua
|
||||||
-- Create a brush we want to draw to the keyboard at a later time
|
-- 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.
|
-- This function will be called after every profile draw.
|
||||||
function drawHandler(profile, eventArgs)
|
function drawHandler(profile, eventArgs)
|
||||||
-- Draw a line from the top left to the bottom left
|
-- Draw a line from the top left to the bottom left
|
||||||
eventArgs.Drawing.DrawLine(redBrush, 0, 0, 5, 5, 1);
|
eventArgs.Drawing.DrawLine(redBrush, 0, 0, 5, 5, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
||||||
Events.DeviceDrawing.add(drawHandler);
|
Events.DeviceDrawing.add(drawHandler)
|
||||||
```
|
```
|
||||||
#### Result:
|
#### Result:
|
||||||
Drawing the line would look like this:
|
Drawing the line would look like this:
|
||||||
@ -77,7 +77,7 @@ Drawing the line would look like this:
|
|||||||
Draws an rectangle on the keyboard.
|
Draws an rectangle on the keyboard.
|
||||||
#### Syntax:
|
#### Syntax:
|
||||||
```lua
|
```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
|
##### Required arguments
|
||||||
- **brush:** A [brush](https://github.com/SpoinkyNL/Artemis/wiki/brushes) used to fill the rectangle
|
- **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:
|
#### Example:
|
||||||
```lua
|
```lua
|
||||||
-- Create a brush we want to draw to the keyboard at a later time
|
-- 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.
|
-- This function will be called after every profile draw.
|
||||||
function drawHandler(profile, eventArgs)
|
function drawHandler(profile, eventArgs)
|
||||||
-- Draw an rectangle (in this case a square) in the top left
|
-- Draw an rectangle (in this case a square) in the top left
|
||||||
eventArgs.Drawing.DrawRectangle(redBrush, 0, 0, 5, 5);
|
eventArgs.Drawing.DrawRectangle(redBrush, 0, 0, 5, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
||||||
Events.DeviceDrawing.add(drawHandler);
|
Events.DeviceDrawing.add(drawHandler)
|
||||||
```
|
```
|
||||||
#### Result:
|
#### Result:
|
||||||
Drawing the rectangle would look like this:
|
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.
|
**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:
|
#### Syntax:
|
||||||
```lua
|
```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
|
##### Required arguments
|
||||||
- **brush:** A [brush](https://github.com/SpoinkyNL/Artemis/wiki/brushes) used to fill the rectangle
|
- **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:
|
#### Example:
|
||||||
```lua
|
```lua
|
||||||
-- Create a brush we want to draw to the keyboard at a later time
|
-- 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.
|
-- This function will be called after every profile draw.
|
||||||
function drawHandler(profile, eventArgs)
|
function drawHandler(profile, eventArgs)
|
||||||
-- Draw the text "hi" on the keyboard.
|
-- In this example we only want to draw to the keyboard. Each device has it's
|
||||||
eventArgs.Drawing.DrawText(redBrush, 4, -2.4, "hi", 11);
|
-- 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
|
end
|
||||||
|
|
||||||
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
||||||
Events.DeviceDrawing.add(drawHandler);
|
Events.DeviceDrawing.add(drawHandler)
|
||||||
```
|
```
|
||||||
#### Result:
|
#### Result:
|
||||||
Drawing the text would look like this:
|
Drawing the text would look like this:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user