|
| 1 | +# Drawing Settings/State |
| 2 | + |
| 3 | +Methods for setting the drawing state of the library. |
| 4 | + |
| 5 | +### setFont() |
| 6 | + |
| 7 | +This method is called to set the current font in the library. The current font is used when calling the ```text()``` method on this device. |
| 8 | + |
| 9 | +The default font for the device is `5x7`. |
| 10 | + |
| 11 | +```c++ |
| 12 | +void setFont(QwiicFont& theFont) |
| 13 | +void setFont(const QwiicFont * theFont) |
| 14 | +``` |
| 15 | +
|
| 16 | +| Parameter | Type | Description | |
| 17 | +| :--- | :--- | :--- | |
| 18 | +| `theFont` | `QwiicFont` | The font to set as current in the device| |
| 19 | +| `theFont` | `QwiicFont*` | Pointer to the font to set as current in the device.| |
| 20 | +
|
| 21 | +For the library, fonts are added to your program by including them via include files which are part of this library. |
| 22 | +
|
| 23 | +The following fonts are included: |
| 24 | +
|
| 25 | +| Font | Include File | Font Variable | Description| |
| 26 | +| :--- | :--- | :--- | :--- | |
| 27 | +| 5x7 | `<res/qw_fnt_5x7.h>` | `QW_FONT_5X7`| A full, 5 x 7 font| |
| 28 | +| 31x48 | `<res/qw_fnt_31x48.h>` |`QW_FONT_31X48`| A full, 31 x 48 font| |
| 29 | +| Seven Segment | `<res/qw_fnt_7segment.h>` |`QW_FONT_7SEGMENT`| Numbers only| |
| 30 | +| 8x16 | `<res/qw_fnt_8x16.h>` | `QW_FONT_8X16`| A full, 8 x 16 font| |
| 31 | +| Large Numbers | `<res/qw_fnt_largenum.h>` |`QW_FONT_LARGENUM`| Numbers only| |
| 32 | +
|
| 33 | +For each font, the font variables are objects with the following attributes: |
| 34 | +
|
| 35 | +| Attribute | Value | |
| 36 | +| :--- | :--- | |
| 37 | +| `width` | The font width in pixels| |
| 38 | +| `height` | The font height in pixels| |
| 39 | +| `start` | The font start character offset| |
| 40 | +| `n_chars` | The number of characters| |
| 41 | +| `map_width` | The width of the font map| |
| 42 | +
|
| 43 | +Example use of a font object attribute: |
| 44 | +```C++ |
| 45 | +#include <res/qw_fnt_31x48.h> |
| 46 | + |
| 47 | +int myFontWidth = QW_FONT_31X48.width; |
| 48 | +``` |
| 49 | + |
| 50 | +### getFont() |
| 51 | +This method returns the current font for the device. |
| 52 | + |
| 53 | +```c++ |
| 54 | +QwiicFont * getFont(void) |
| 55 | +``` |
| 56 | +
|
| 57 | +| Parameter | Type | Description | |
| 58 | +| :--- | :--- | :--- | |
| 59 | +| return value | `QwiicFont*` | A pointer to the current font. See `setFont()` for font object details.| |
| 60 | +
|
| 61 | +### getFontName() |
| 62 | +
|
| 63 | +This method returns the height in pixels of a provided String based on the current device font. |
| 64 | +
|
| 65 | +```c++ |
| 66 | +String getFontName(void) |
| 67 | +``` |
| 68 | + |
| 69 | +| Parameter | Type | Description | |
| 70 | +| :--- | :--- | :--- | |
| 71 | +| return value | String | The name of the current font.| |
| 72 | + |
| 73 | +### getStringWidth() |
| 74 | + |
| 75 | +This method returns the width in pixels of a provided String based on the current device font. |
| 76 | + |
| 77 | +```c++ |
| 78 | +unsigned int getStringWidth(String text) |
| 79 | +``` |
| 80 | +
|
| 81 | +| Parameter | Type | Description | |
| 82 | +| :--- | :--- | :--- | |
| 83 | +| text | `String` | The string used to determine width | |
| 84 | +| return value | `unsigned int` | The width of the provide string, as determined using the current font.| |
| 85 | +
|
| 86 | +### getStringHeight() |
| 87 | +
|
| 88 | +This method returns the height in pixels of a provided String based on the current device font. |
| 89 | +
|
| 90 | +```c++ |
| 91 | +unsigned int getStringHeight(String text) |
| 92 | +``` |
| 93 | + |
| 94 | +| Parameter | Type | Description | |
| 95 | +| :--- | :--- | :--- | |
| 96 | +| text | `String` | The string used to determine height | |
| 97 | +| return value | `unsigned int` | The height of the provide string, as determined using the current font.| |
| 98 | + |
| 99 | +### setDrawMode() |
| 100 | +This method sets the current draw mode for the library. The draw mode determines how pixels are set on the screen during drawing operations. |
| 101 | + |
| 102 | +```c++ |
| 103 | +void setDrawMode(grRasterOp_t rop) |
| 104 | +``` |
| 105 | +
|
| 106 | +| Parameter | Type | Description | |
| 107 | +| :--- | :--- | :--- | |
| 108 | +| rop | `grRasterOp_t` | The raster operation (ROP) to set the graphics system to.| |
| 109 | +
|
| 110 | +Raster operations device how source (pixels to draw) are represented on the destination device. The available Raster Operation (ROP) codes are: |
| 111 | +
|
| 112 | +| ROP Code | Description| |
| 113 | +| :--- | :--- | |
| 114 | +| grROPCopy | **default** Drawn pixel values are copied to the device screen| |
| 115 | +| grROPNotCopy | A not operation is applied to the source value before copying to screen| |
| 116 | +| grROPNot | A not operation is applied to the destination (screen) value | |
| 117 | +| grROPXOR | A XOR operation is performed between the source and destination values| |
| 118 | +| grROPBlack | A value of 0, or black is drawn to the destination | |
| 119 | +| grROPWhite | A value of 1, or black is drawn to the destination | |
| 120 | +
|
| 121 | +
|
| 122 | +### getDrawMode() |
| 123 | +This method returns the current draw mode for the library. The draw mode determines how pixels are set on the screen during drawing operations. |
| 124 | +
|
| 125 | +```c++ |
| 126 | +grRasterOp_t getDrawMode(void) |
| 127 | +``` |
| 128 | + |
| 129 | +| Parameter | Type | Description | |
| 130 | +| :--- | :--- | :--- | |
| 131 | +| return value | `grRasterOp_t` | The current aster operation (ROP) of the graphics system.| |
0 commit comments