From 1f5f70e6cb83890fe6b00c343c313e007748047e Mon Sep 17 00:00:00 2001 From: Robert Beekman Date: Thu, 3 Nov 2016 17:40:04 +0100 Subject: [PATCH] Updated Drawing (markdown) --- Drawing.md | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 128 insertions(+), 6 deletions(-) diff --git a/Drawing.md b/Drawing.md index 2967368..c658132 100644 --- a/Drawing.md +++ b/Drawing.md @@ -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 -``` \ No newline at end of file +-- 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.. \ No newline at end of file