2 * This file is part of Cleanflight, Betaflight and INAV.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
6 * You can obtain one at http://mozilla.org/MPL/2.0/.
8 * Alternatively, the contents of this file may be used under the terms
9 * of the GNU General Public License Version 3, as described below:
11 * This file is free software: you may copy, redistribute and/or modify
12 * it under the terms of the GNU General Public License as published by the
13 * Free Software Foundation, either version 3 of the License, or (at your
14 * option) any later version.
16 * This file is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 * Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see http://www.gnu.org/licenses/.
24 * @author Alberto Garcia Hierro <alberto@garciahierro.com>
29 #include "drivers/display_canvas.h"
31 void displayCanvasSetStrokeColor(displayCanvas_t
*displayCanvas
, displayCanvasColor_e color
)
33 if (displayCanvas
->vTable
->setStrokeColor
) {
34 displayCanvas
->vTable
->setStrokeColor(displayCanvas
, color
);
38 void displayCanvasSetFillColor(displayCanvas_t
*displayCanvas
, displayCanvasColor_e color
)
40 if (displayCanvas
->vTable
->setFillColor
) {
41 displayCanvas
->vTable
->setFillColor(displayCanvas
, color
);
45 void displayCanvasSetStrokeAndFillColor(displayCanvas_t
*displayCanvas
, displayCanvasColor_e color
)
47 if (displayCanvas
->vTable
->setStrokeAndFillColor
) {
48 displayCanvas
->vTable
->setStrokeAndFillColor(displayCanvas
, color
);
50 displayCanvasSetStrokeColor(displayCanvas
, color
);
51 displayCanvasSetFillColor(displayCanvas
, color
);
55 void displayCanvasSetColorInversion(displayCanvas_t
*displayCanvas
, bool inverted
)
57 if (displayCanvas
->vTable
->setColorInversion
) {
58 displayCanvas
->vTable
->setColorInversion(displayCanvas
, inverted
);
62 void displayCanvasSetPixel(displayCanvas_t
*displayCanvas
, int x
, int y
, displayCanvasColor_e color
)
64 if (displayCanvas
->vTable
->setPixel
) {
65 displayCanvas
->vTable
->setPixel(displayCanvas
, x
, y
, color
);
69 void displayCanvasSetPixelToStrokeColor(displayCanvas_t
*displayCanvas
, int x
, int y
)
71 if (displayCanvas
->vTable
->setPixelToStrokeColor
) {
72 displayCanvas
->vTable
->setPixelToStrokeColor(displayCanvas
, x
, y
);
76 void displayCanvasSetPixelToFillColor(displayCanvas_t
*displayCanvas
, int x
, int y
)
78 if (displayCanvas
->vTable
->setPixelToFillColor
) {
79 displayCanvas
->vTable
->setPixelToFillColor(displayCanvas
, x
, y
);
83 void displayCanvasSetStrokeWidth(displayCanvas_t
*displayCanvas
, unsigned w
)
85 if (displayCanvas
->vTable
->setStrokeWidth
) {
86 displayCanvas
->vTable
->setStrokeWidth(displayCanvas
, w
);
90 void displayCanvasSetLineOutlineType(displayCanvas_t
*displayCanvas
, displayCanvasOutlineType_e outlineType
)
92 if (displayCanvas
->vTable
->setLineOutlineType
) {
93 displayCanvas
->vTable
->setLineOutlineType(displayCanvas
, outlineType
);
97 void displayCanvasSetLineOutlineColor(displayCanvas_t
*displayCanvas
, displayCanvasColor_e outlineColor
)
99 if (displayCanvas
->vTable
->setLineOutlineColor
) {
100 displayCanvas
->vTable
->setLineOutlineColor(displayCanvas
, outlineColor
);
104 void displayCanvasClipToRect(displayCanvas_t
*displayCanvas
, int x
, int y
, int w
, int h
)
106 if (displayCanvas
->vTable
->clipToRect
) {
107 displayCanvas
->vTable
->clipToRect(displayCanvas
, x
, y
, w
, h
);
111 void displayCanvasClearRect(displayCanvas_t
*displayCanvas
, int x
, int y
, int w
, int h
)
113 if (displayCanvas
->vTable
->clearRect
) {
114 displayCanvas
->vTable
->clearRect(displayCanvas
, x
, y
, w
, h
);
118 void displayCanvasResetDrawingState(displayCanvas_t
*displayCanvas
)
120 if (displayCanvas
->vTable
->resetDrawingState
) {
121 displayCanvas
->vTable
->resetDrawingState(displayCanvas
);
125 void displayCanvasDrawCharacter(displayCanvas_t
*displayCanvas
, int x
, int y
, uint16_t chr
, displayCanvasBitmapOption_t opts
)
127 if (displayCanvas
->vTable
->drawCharacter
) {
128 displayCanvas
->vTable
->drawCharacter(displayCanvas
, x
, y
, chr
, opts
);
132 void displayCanvasDrawCharacterMask(displayCanvas_t
*displayCanvas
, int x
, int y
, uint16_t chr
, displayCanvasColor_e color
, displayCanvasBitmapOption_t opts
)
134 if (displayCanvas
->vTable
->drawCharacterMask
) {
135 displayCanvas
->vTable
->drawCharacterMask(displayCanvas
, x
, y
, chr
, color
, opts
);
139 void displayCanvasDrawString(displayCanvas_t
*displayCanvas
, int x
, int y
, const char *s
, displayCanvasBitmapOption_t opts
)
141 if (displayCanvas
->vTable
->drawString
) {
142 displayCanvas
->vTable
->drawString(displayCanvas
, x
, y
, s
, opts
);
146 void displayCanvasDrawStringMask(displayCanvas_t
*displayCanvas
, int x
, int y
, const char *s
, displayCanvasColor_e color
, displayCanvasBitmapOption_t opts
)
148 if (displayCanvas
->vTable
->drawStringMask
) {
149 displayCanvas
->vTable
->drawStringMask(displayCanvas
, x
, y
, s
, color
, opts
);
153 void displayCanvasMoveToPoint(displayCanvas_t
*displayCanvas
, int x
, int y
)
155 if (displayCanvas
->vTable
->moveToPoint
) {
156 displayCanvas
->vTable
->moveToPoint(displayCanvas
, x
, y
);
160 void displayCanvasStrokeLineToPoint(displayCanvas_t
*displayCanvas
, int x
, int y
)
162 if (displayCanvas
->vTable
->strokeLineToPoint
) {
163 displayCanvas
->vTable
->strokeLineToPoint(displayCanvas
, x
, y
);
167 void displayCanvasStrokeTriangle(displayCanvas_t
*displayCanvas
, int x1
, int y1
, int x2
, int y2
, int x3
, int y3
)
169 if (displayCanvas
->vTable
->strokeTriangle
) {
170 displayCanvas
->vTable
->strokeTriangle(displayCanvas
, x1
, y1
, x2
, y2
, x3
, y3
);
174 void displayCanvasFillTriangle(displayCanvas_t
*displayCanvas
, int x1
, int y1
, int x2
, int y2
, int x3
, int y3
)
176 if (displayCanvas
->vTable
->fillTriangle
) {
177 displayCanvas
->vTable
->fillTriangle(displayCanvas
, x1
, y1
, x2
, y2
, x3
, y3
);
181 void displayCanvasFillStrokeTriangle(displayCanvas_t
*displayCanvas
, int x1
, int y1
, int x2
, int y2
, int x3
, int y3
)
183 if (displayCanvas
->vTable
->fillStrokeTriangle
) {
184 displayCanvas
->vTable
->fillStrokeTriangle(displayCanvas
, x1
, y1
, x2
, y2
, x3
, y3
);
188 void displayCanvasStrokeRect(displayCanvas_t
*displayCanvas
, int x
, int y
, int w
, int h
)
190 if (displayCanvas
->vTable
->strokeRect
) {
191 displayCanvas
->vTable
->strokeRect(displayCanvas
, x
, y
, w
, h
);
195 void displayCanvasFillRect(displayCanvas_t
*displayCanvas
, int x
, int y
, int w
, int h
)
197 if (displayCanvas
->vTable
->fillRect
) {
198 displayCanvas
->vTable
->fillRect(displayCanvas
, x
, y
, w
, h
);
202 void displayCanvasFillStrokeRect(displayCanvas_t
*displayCanvas
, int x
, int y
, int w
, int h
)
204 if (displayCanvas
->vTable
->fillStrokeRect
) {
205 displayCanvas
->vTable
->fillStrokeRect(displayCanvas
, x
, y
, w
, h
);
209 void displayCanvasStrokeEllipseInRect(displayCanvas_t
*displayCanvas
, int x
, int y
, int w
, int h
)
211 if (displayCanvas
->vTable
->strokeEllipseInRect
) {
212 displayCanvas
->vTable
->strokeEllipseInRect(displayCanvas
, x
, y
, w
, h
);
216 void displayCanvasFillEllipseInRect(displayCanvas_t
*displayCanvas
, int x
, int y
, int w
, int h
)
218 if (displayCanvas
->vTable
->fillEllipseInRect
) {
219 displayCanvas
->vTable
->fillEllipseInRect(displayCanvas
, x
, y
, w
, h
);
223 void displayCanvasFillStrokeEllipseInRect(displayCanvas_t
*displayCanvas
, int x
, int y
, int w
, int h
)
225 if (displayCanvas
->vTable
->fillStrokeEllipseInRect
) {
226 displayCanvas
->vTable
->fillStrokeEllipseInRect(displayCanvas
, x
, y
, w
, h
);
230 void displayCanvasCtmReset(displayCanvas_t
*displayCanvas
)
232 if (displayCanvas
->vTable
->ctmReset
) {
233 displayCanvas
->vTable
->ctmReset(displayCanvas
);
237 void displayCanvasCtmSet(displayCanvas_t
*displayCanvas
, float m11
, float m12
, float m21
, float m22
, float m31
, float m32
)
239 if (displayCanvas
->vTable
->ctmSet
) {
240 displayCanvas
->vTable
->ctmSet(displayCanvas
, m11
, m12
, m21
, m22
, m31
, m32
);
244 void displayCanvasCtmTranslate(displayCanvas_t
*displayCanvas
, float tx
, float ty
)
246 if (displayCanvas
->vTable
->ctmTranslate
) {
247 displayCanvas
->vTable
->ctmTranslate(displayCanvas
, tx
, ty
);
251 void displayCanvasCtmScale(displayCanvas_t
*displayCanvas
, float sx
, float sy
)
253 if (displayCanvas
->vTable
->ctmScale
) {
254 displayCanvas
->vTable
->ctmScale(displayCanvas
, sx
, sy
);
258 void displayCanvasCtmRotate(displayCanvas_t
*displayCanvas
, float r
)
260 if (displayCanvas
->vTable
->ctmRotate
) {
261 displayCanvas
->vTable
->ctmRotate(displayCanvas
, r
);
265 void displayCanvasContextPush(displayCanvas_t
*displayCanvas
)
267 if (displayCanvas
->vTable
->contextPush
) {
268 displayCanvas
->vTable
->contextPush(displayCanvas
);
272 void displayCanvasContextPop(displayCanvas_t
*displayCanvas
)
274 if (displayCanvas
->vTable
->contextPop
) {
275 displayCanvas
->vTable
->contextPop(displayCanvas
);