A basic graphics package for the LPC4088 Display Module.
Dependents: lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI lpc4088_displaymodule_fs_aid ... more
Fork of DMBasicGUI by
lpc_swim/lpc_swim.c@22:f0d00f29bfeb, 2019-11-04 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Nov 04 14:31:50 2019 +0000
- Revision:
- 22:f0d00f29bfeb
- Parent:
- 17:6e2abf107800
More updates related to mbed OS 5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:4977187e90c7 | 1 | /* |
embeddedartists | 0:4977187e90c7 | 2 | * @brief Simple Windowing Interface Manager (SWIM) |
embeddedartists | 0:4977187e90c7 | 3 | * |
embeddedartists | 0:4977187e90c7 | 4 | * @note |
embeddedartists | 0:4977187e90c7 | 5 | * Copyright(C) NXP Semiconductors, 2012 |
embeddedartists | 0:4977187e90c7 | 6 | * All rights reserved. |
embeddedartists | 0:4977187e90c7 | 7 | * |
embeddedartists | 0:4977187e90c7 | 8 | * @par |
embeddedartists | 0:4977187e90c7 | 9 | * Software that is described herein is for illustrative purposes only |
embeddedartists | 0:4977187e90c7 | 10 | * which provides customers with programming information regarding the |
embeddedartists | 0:4977187e90c7 | 11 | * LPC products. This software is supplied "AS IS" without any warranties of |
embeddedartists | 0:4977187e90c7 | 12 | * any kind, and NXP Semiconductors and its licensor disclaim any and |
embeddedartists | 0:4977187e90c7 | 13 | * all warranties, express or implied, including all implied warranties of |
embeddedartists | 0:4977187e90c7 | 14 | * merchantability, fitness for a particular purpose and non-infringement of |
embeddedartists | 0:4977187e90c7 | 15 | * intellectual property rights. NXP Semiconductors assumes no responsibility |
embeddedartists | 0:4977187e90c7 | 16 | * or liability for the use of the software, conveys no license or rights under any |
embeddedartists | 0:4977187e90c7 | 17 | * patent, copyright, mask work right, or any other intellectual property rights in |
embeddedartists | 0:4977187e90c7 | 18 | * or to any products. NXP Semiconductors reserves the right to make changes |
embeddedartists | 0:4977187e90c7 | 19 | * in the software without notification. NXP Semiconductors also makes no |
embeddedartists | 0:4977187e90c7 | 20 | * representation or warranty that such application will be suitable for the |
embeddedartists | 0:4977187e90c7 | 21 | * specified use without further testing or modification. |
embeddedartists | 0:4977187e90c7 | 22 | * |
embeddedartists | 0:4977187e90c7 | 23 | * @par |
embeddedartists | 0:4977187e90c7 | 24 | * Permission to use, copy, modify, and distribute this software and its |
embeddedartists | 0:4977187e90c7 | 25 | * documentation is hereby granted, under NXP Semiconductors' and its |
embeddedartists | 0:4977187e90c7 | 26 | * licensor's relevant copyrights in the software, without fee, provided that it |
embeddedartists | 0:4977187e90c7 | 27 | * is used in conjunction with NXP Semiconductors microcontrollers. This |
embeddedartists | 0:4977187e90c7 | 28 | * copyright, permission, and disclaimer notice must appear in all copies of |
embeddedartists | 0:4977187e90c7 | 29 | * this code. |
embeddedartists | 0:4977187e90c7 | 30 | */ |
embeddedartists | 0:4977187e90c7 | 31 | |
embeddedartists | 0:4977187e90c7 | 32 | #include "lpc_swim.h" |
embeddedartists | 0:4977187e90c7 | 33 | #include "lpc_fonts.h" |
embeddedartists | 0:4977187e90c7 | 34 | #include "lpc_helvr10.h" |
embeddedartists | 0:4977187e90c7 | 35 | |
embeddedartists | 0:4977187e90c7 | 36 | /***************************************************************************** |
embeddedartists | 0:4977187e90c7 | 37 | * Private types/enumerations/variables |
embeddedartists | 0:4977187e90c7 | 38 | ****************************************************************************/ |
embeddedartists | 0:4977187e90c7 | 39 | |
embeddedartists | 17:6e2abf107800 | 40 | static const FONT_T* defaultFont = (FONT_T*)&font_helvr10; |
embeddedartists | 17:6e2abf107800 | 41 | |
embeddedartists | 0:4977187e90c7 | 42 | /***************************************************************************** |
embeddedartists | 0:4977187e90c7 | 43 | * Public types/enumerations/variables |
embeddedartists | 0:4977187e90c7 | 44 | ****************************************************************************/ |
embeddedartists | 0:4977187e90c7 | 45 | |
embeddedartists | 0:4977187e90c7 | 46 | /***************************************************************************** |
embeddedartists | 0:4977187e90c7 | 47 | * Private functions |
embeddedartists | 0:4977187e90c7 | 48 | ****************************************************************************/ |
embeddedartists | 0:4977187e90c7 | 49 | |
embeddedartists | 0:4977187e90c7 | 50 | /* Absolute value function */ |
embeddedartists | 0:4977187e90c7 | 51 | static int32_t swim_abs(int32_t v1) |
embeddedartists | 0:4977187e90c7 | 52 | { |
embeddedartists | 0:4977187e90c7 | 53 | if (v1 > 0) { |
embeddedartists | 0:4977187e90c7 | 54 | return v1; |
embeddedartists | 0:4977187e90c7 | 55 | } |
embeddedartists | 0:4977187e90c7 | 56 | |
embeddedartists | 0:4977187e90c7 | 57 | return -v1; |
embeddedartists | 0:4977187e90c7 | 58 | } |
embeddedartists | 0:4977187e90c7 | 59 | |
embeddedartists | 0:4977187e90c7 | 60 | /* Draw a line on the physical display */ |
embeddedartists | 0:4977187e90c7 | 61 | static void swim_put_line_raw(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 62 | int32_t x1, |
embeddedartists | 0:4977187e90c7 | 63 | int32_t y1, |
embeddedartists | 0:4977187e90c7 | 64 | int32_t x2, |
embeddedartists | 0:4977187e90c7 | 65 | int32_t y2) |
embeddedartists | 0:4977187e90c7 | 66 | { |
embeddedartists | 0:4977187e90c7 | 67 | int32_t e2, sx, sy, dx, dy, err; |
embeddedartists | 0:4977187e90c7 | 68 | |
embeddedartists | 0:4977187e90c7 | 69 | /* calculate delta_x and delta_y */ |
embeddedartists | 0:4977187e90c7 | 70 | dx = swim_abs(x2 - x1); |
embeddedartists | 0:4977187e90c7 | 71 | dy = swim_abs(y2 - y1); |
embeddedartists | 0:4977187e90c7 | 72 | |
embeddedartists | 0:4977187e90c7 | 73 | /* set the direction for the step for both x and y, and |
embeddedartists | 0:4977187e90c7 | 74 | initialize the error */ |
embeddedartists | 0:4977187e90c7 | 75 | if (x1 < x2) { |
embeddedartists | 0:4977187e90c7 | 76 | sx = 1; |
embeddedartists | 0:4977187e90c7 | 77 | } |
embeddedartists | 0:4977187e90c7 | 78 | else { |
embeddedartists | 0:4977187e90c7 | 79 | sx = -1; |
embeddedartists | 0:4977187e90c7 | 80 | } |
embeddedartists | 0:4977187e90c7 | 81 | |
embeddedartists | 0:4977187e90c7 | 82 | if (y1 < y2) { |
embeddedartists | 0:4977187e90c7 | 83 | sy = 1; |
embeddedartists | 0:4977187e90c7 | 84 | } |
embeddedartists | 0:4977187e90c7 | 85 | else { |
embeddedartists | 0:4977187e90c7 | 86 | sy = -1; |
embeddedartists | 0:4977187e90c7 | 87 | } |
embeddedartists | 0:4977187e90c7 | 88 | |
embeddedartists | 0:4977187e90c7 | 89 | err = dx - dy; |
embeddedartists | 0:4977187e90c7 | 90 | |
embeddedartists | 0:4977187e90c7 | 91 | while (1) { |
embeddedartists | 0:4977187e90c7 | 92 | if ((x1 >= 0) && (x1 <= win->xpsize) && |
embeddedartists | 0:4977187e90c7 | 93 | (y1 >= 0) && (y1 <= win->ypsize)) { |
embeddedartists | 0:4977187e90c7 | 94 | swim_put_pixel_physical(win, x1, y1, win->pen); |
embeddedartists | 0:4977187e90c7 | 95 | } |
embeddedartists | 0:4977187e90c7 | 96 | |
embeddedartists | 0:4977187e90c7 | 97 | if ((x1 == x2) && (y1 == y2)) { |
embeddedartists | 0:4977187e90c7 | 98 | return; |
embeddedartists | 0:4977187e90c7 | 99 | } |
embeddedartists | 0:4977187e90c7 | 100 | |
embeddedartists | 0:4977187e90c7 | 101 | e2 = 2 * err; |
embeddedartists | 0:4977187e90c7 | 102 | if (e2 > -dy) { |
embeddedartists | 0:4977187e90c7 | 103 | err -= dy; |
embeddedartists | 0:4977187e90c7 | 104 | x1 += sx; |
embeddedartists | 0:4977187e90c7 | 105 | } |
embeddedartists | 0:4977187e90c7 | 106 | if (e2 < dx) { |
embeddedartists | 0:4977187e90c7 | 107 | err += dx; |
embeddedartists | 0:4977187e90c7 | 108 | y1 += sy; |
embeddedartists | 0:4977187e90c7 | 109 | } |
embeddedartists | 0:4977187e90c7 | 110 | } |
embeddedartists | 0:4977187e90c7 | 111 | } |
embeddedartists | 0:4977187e90c7 | 112 | |
embeddedartists | 0:4977187e90c7 | 113 | /* Initializes a window and the default values for the window */ |
embeddedartists | 0:4977187e90c7 | 114 | static BOOL_32 swim_window_open_p(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 115 | int32_t xsize, |
embeddedartists | 0:4977187e90c7 | 116 | int32_t ysize, |
embeddedartists | 0:4977187e90c7 | 117 | COLOR_T *fbaddr, |
embeddedartists | 0:4977187e90c7 | 118 | int32_t xwin_min, |
embeddedartists | 0:4977187e90c7 | 119 | int32_t ywin_min, |
embeddedartists | 0:4977187e90c7 | 120 | int32_t xwin_max, |
embeddedartists | 0:4977187e90c7 | 121 | int32_t ywin_max, |
embeddedartists | 0:4977187e90c7 | 122 | int32_t border_width, |
embeddedartists | 0:4977187e90c7 | 123 | COLOR_T pcolor, |
embeddedartists | 0:4977187e90c7 | 124 | COLOR_T bkcolor, |
embeddedartists | 0:4977187e90c7 | 125 | COLOR_T fcolor, |
embeddedartists | 0:4977187e90c7 | 126 | BOOL_32 clear) |
embeddedartists | 0:4977187e90c7 | 127 | { |
embeddedartists | 0:4977187e90c7 | 128 | int32_t i; |
embeddedartists | 0:4977187e90c7 | 129 | BOOL_32 init = false; |
embeddedartists | 0:4977187e90c7 | 130 | |
embeddedartists | 0:4977187e90c7 | 131 | /* Before continuing, check to see that the window size is |
embeddedartists | 0:4977187e90c7 | 132 | in the physical dimensions of the display */ |
embeddedartists | 0:4977187e90c7 | 133 | if ((xwin_min >= 0) && (ywin_min >= 0) && |
embeddedartists | 0:4977187e90c7 | 134 | (xwin_max < xsize) && (ywin_max < ysize)) { |
embeddedartists | 0:4977187e90c7 | 135 | init = true; |
embeddedartists | 0:4977187e90c7 | 136 | } |
embeddedartists | 0:4977187e90c7 | 137 | else { |
embeddedartists | 0:4977187e90c7 | 138 | /* Window size is out of the physical display size, so it |
embeddedartists | 0:4977187e90c7 | 139 | should be invalidated */ |
embeddedartists | 0:4977187e90c7 | 140 | win->winused = 0x0; |
embeddedartists | 0:4977187e90c7 | 141 | } |
embeddedartists | 0:4977187e90c7 | 142 | |
embeddedartists | 0:4977187e90c7 | 143 | if (init == true) { |
embeddedartists | 0:4977187e90c7 | 144 | /* Save physical display dimensions */ |
embeddedartists | 0:4977187e90c7 | 145 | win->xpsize = xsize; |
embeddedartists | 0:4977187e90c7 | 146 | win->ypsize = ysize; |
embeddedartists | 0:4977187e90c7 | 147 | |
embeddedartists | 0:4977187e90c7 | 148 | /* Save frame buffer address */ |
embeddedartists | 0:4977187e90c7 | 149 | win->fb = fbaddr; |
embeddedartists | 0:4977187e90c7 | 150 | |
embeddedartists | 0:4977187e90c7 | 151 | /* Save physical window dimensions and default colors */ |
embeddedartists | 0:4977187e90c7 | 152 | win->xpmin = xwin_min; |
embeddedartists | 0:4977187e90c7 | 153 | win->ypmin = ywin_min; |
embeddedartists | 0:4977187e90c7 | 154 | win->xpmax = xwin_max; |
embeddedartists | 0:4977187e90c7 | 155 | win->ypmax = ywin_max; |
embeddedartists | 0:4977187e90c7 | 156 | win->pen = pcolor; |
embeddedartists | 0:4977187e90c7 | 157 | win->bkg = bkcolor; |
embeddedartists | 0:4977187e90c7 | 158 | win->fill = fcolor; |
embeddedartists | 0:4977187e90c7 | 159 | |
embeddedartists | 0:4977187e90c7 | 160 | /* Compute physical window dimensions of draw area only */ |
embeddedartists | 0:4977187e90c7 | 161 | win->xpvmin = xwin_min + border_width; |
embeddedartists | 0:4977187e90c7 | 162 | win->ypvmin = ywin_min + border_width; |
embeddedartists | 0:4977187e90c7 | 163 | win->xpvmax = xwin_max - border_width; |
embeddedartists | 0:4977187e90c7 | 164 | win->ypvmax = ywin_max - border_width; |
embeddedartists | 0:4977187e90c7 | 165 | |
embeddedartists | 0:4977187e90c7 | 166 | /* Compute virtual window size of draw area */ |
embeddedartists | 0:4977187e90c7 | 167 | win->xvsize = xwin_max - xwin_min - 2 * border_width; |
embeddedartists | 0:4977187e90c7 | 168 | win->yvsize = ywin_max - ywin_min - 2 * border_width; |
embeddedartists | 0:4977187e90c7 | 169 | |
embeddedartists | 0:4977187e90c7 | 170 | /* Fill in any unused border padding between draw area and border |
embeddedartists | 0:4977187e90c7 | 171 | will fill color */ |
embeddedartists | 0:4977187e90c7 | 172 | for (i = 0; i < border_width; i++) { |
embeddedartists | 0:4977187e90c7 | 173 | swim_put_line_raw(win, (xwin_min + i), |
embeddedartists | 0:4977187e90c7 | 174 | (ywin_min + i), (xwin_max - i), (ywin_min + i)); |
embeddedartists | 0:4977187e90c7 | 175 | swim_put_line_raw(win, (xwin_max - i), |
embeddedartists | 0:4977187e90c7 | 176 | (ywin_min + i), (xwin_max - i), (ywin_max - i)); |
embeddedartists | 0:4977187e90c7 | 177 | swim_put_line_raw(win, (xwin_max - i), |
embeddedartists | 0:4977187e90c7 | 178 | (ywin_max - i), (xwin_min + i), (ywin_max - i)); |
embeddedartists | 0:4977187e90c7 | 179 | swim_put_line_raw(win, (xwin_min + i), |
embeddedartists | 0:4977187e90c7 | 180 | (ywin_max - i), (xwin_min + i), (ywin_min + i)); |
embeddedartists | 0:4977187e90c7 | 181 | } |
embeddedartists | 0:4977187e90c7 | 182 | |
embeddedartists | 0:4977187e90c7 | 183 | /* Clear draw area with background color */ |
embeddedartists | 0:4977187e90c7 | 184 | if (clear == true) { |
embeddedartists | 0:4977187e90c7 | 185 | swim_clear_screen(win, bkcolor); |
embeddedartists | 0:4977187e90c7 | 186 | } |
embeddedartists | 0:4977187e90c7 | 187 | |
embeddedartists | 0:4977187e90c7 | 188 | /* Use the default font and make background transparent */ |
embeddedartists | 17:6e2abf107800 | 189 | win->font = (FONT_T*)defaultFont; |
embeddedartists | 0:4977187e90c7 | 190 | |
embeddedartists | 0:4977187e90c7 | 191 | /* Set starting text position in upper left of window */ |
embeddedartists | 0:4977187e90c7 | 192 | win->xvpos = win->xpvmin; |
embeddedartists | 0:4977187e90c7 | 193 | win->yvpos = win->ypvmin; |
embeddedartists | 0:4977187e90c7 | 194 | } |
embeddedartists | 0:4977187e90c7 | 195 | |
embeddedartists | 0:4977187e90c7 | 196 | return init; |
embeddedartists | 0:4977187e90c7 | 197 | } |
embeddedartists | 0:4977187e90c7 | 198 | |
embeddedartists | 0:4977187e90c7 | 199 | /* Circle support function */ |
embeddedartists | 0:4977187e90c7 | 200 | static void swim_plot4points(SWIM_WINDOW_T *win, int32_t cx, int32_t cy, int32_t x, int32_t y, int32_t Filled) |
embeddedartists | 0:4977187e90c7 | 201 | { |
embeddedartists | 0:4977187e90c7 | 202 | int16_t x0, x1, y0, y1; |
embeddedartists | 0:4977187e90c7 | 203 | |
embeddedartists | 0:4977187e90c7 | 204 | y0 = cy + y; |
embeddedartists | 0:4977187e90c7 | 205 | y1 = cy - y; |
embeddedartists | 0:4977187e90c7 | 206 | if ( Filled ) { |
embeddedartists | 0:4977187e90c7 | 207 | for ( x0 = cx - x; x0 <= cx + x; x0++ ) { |
embeddedartists | 0:4977187e90c7 | 208 | swim_put_pixel_physical(win, x0, y0, win->pen); |
embeddedartists | 0:4977187e90c7 | 209 | swim_put_pixel_physical(win, x0, y1, win->pen); |
embeddedartists | 0:4977187e90c7 | 210 | } |
embeddedartists | 0:4977187e90c7 | 211 | } |
embeddedartists | 0:4977187e90c7 | 212 | else { |
embeddedartists | 0:4977187e90c7 | 213 | x0 = cx + x; |
embeddedartists | 0:4977187e90c7 | 214 | x1 = cx - x; |
embeddedartists | 0:4977187e90c7 | 215 | swim_put_pixel_physical(win, x0, y0, win->pen); |
embeddedartists | 0:4977187e90c7 | 216 | if (x != 0) { |
embeddedartists | 0:4977187e90c7 | 217 | swim_put_pixel_physical(win, x1, y0, win->pen); |
embeddedartists | 0:4977187e90c7 | 218 | } |
embeddedartists | 0:4977187e90c7 | 219 | if (y != 0) { |
embeddedartists | 0:4977187e90c7 | 220 | swim_put_pixel_physical(win, x0, y1, win->pen); |
embeddedartists | 0:4977187e90c7 | 221 | } |
embeddedartists | 0:4977187e90c7 | 222 | if (( x != 0) && ( y != 0) ) { |
embeddedartists | 0:4977187e90c7 | 223 | swim_put_pixel_physical(win, x1, y1, win->pen); |
embeddedartists | 0:4977187e90c7 | 224 | } |
embeddedartists | 0:4977187e90c7 | 225 | } |
embeddedartists | 0:4977187e90c7 | 226 | } |
embeddedartists | 0:4977187e90c7 | 227 | |
embeddedartists | 0:4977187e90c7 | 228 | /* Circle support function */ |
embeddedartists | 0:4977187e90c7 | 229 | static void swim_plot8points(SWIM_WINDOW_T *win, int32_t cx, int32_t cy, int32_t x, int32_t y, int32_t Filled) |
embeddedartists | 0:4977187e90c7 | 230 | { |
embeddedartists | 0:4977187e90c7 | 231 | swim_plot4points(win, cx, cy, x, y, Filled); |
embeddedartists | 0:4977187e90c7 | 232 | if (x != y) { |
embeddedartists | 0:4977187e90c7 | 233 | swim_plot4points(win, cx, cy, y, x, Filled); |
embeddedartists | 0:4977187e90c7 | 234 | } |
embeddedartists | 0:4977187e90c7 | 235 | } |
embeddedartists | 0:4977187e90c7 | 236 | |
embeddedartists | 0:4977187e90c7 | 237 | /*********************************************************************** |
embeddedartists | 0:4977187e90c7 | 238 | * Public functions |
embeddedartists | 0:4977187e90c7 | 239 | **********************************************************************/ |
embeddedartists | 0:4977187e90c7 | 240 | |
embeddedartists | 0:4977187e90c7 | 241 | /* Puts a pixel at the virtual X, Y coordinate in the window */ |
embeddedartists | 0:4977187e90c7 | 242 | void swim_put_pixel(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 243 | int32_t x1, |
embeddedartists | 0:4977187e90c7 | 244 | int32_t y1) |
embeddedartists | 0:4977187e90c7 | 245 | { |
embeddedartists | 0:4977187e90c7 | 246 | int16_t realx, realy; |
embeddedartists | 0:4977187e90c7 | 247 | |
embeddedartists | 0:4977187e90c7 | 248 | /* Convert virtual coordinate to physical coordinate taking into |
embeddedartists | 0:4977187e90c7 | 249 | consideration the border size of the window */ |
embeddedartists | 0:4977187e90c7 | 250 | realx = win->xpvmin + x1; |
embeddedartists | 0:4977187e90c7 | 251 | realy = win->ypvmin + y1; |
embeddedartists | 0:4977187e90c7 | 252 | |
embeddedartists | 0:4977187e90c7 | 253 | /* Only put the pixel in the window if it fits in the window */ |
embeddedartists | 0:4977187e90c7 | 254 | if ((realx <= win->xpvmax) && |
embeddedartists | 0:4977187e90c7 | 255 | (realy <= win->ypvmax)) { |
embeddedartists | 0:4977187e90c7 | 256 | swim_put_pixel_physical(win, realx, realy, win->pen); |
embeddedartists | 0:4977187e90c7 | 257 | } |
embeddedartists | 0:4977187e90c7 | 258 | } |
embeddedartists | 0:4977187e90c7 | 259 | |
embeddedartists | 0:4977187e90c7 | 260 | /* Draw a line in the virtual window with clipping */ |
embeddedartists | 0:4977187e90c7 | 261 | void swim_put_line(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 262 | int32_t x1, |
embeddedartists | 0:4977187e90c7 | 263 | int32_t y1, |
embeddedartists | 0:4977187e90c7 | 264 | int32_t x2, |
embeddedartists | 0:4977187e90c7 | 265 | int32_t y2) |
embeddedartists | 0:4977187e90c7 | 266 | { |
embeddedartists | 0:4977187e90c7 | 267 | int32_t e2, sx, sy, dx, dy, err; |
embeddedartists | 0:4977187e90c7 | 268 | |
embeddedartists | 0:4977187e90c7 | 269 | /* Convert virtual coordinates to physical coordinates */ |
embeddedartists | 0:4977187e90c7 | 270 | x1 = x1 + win->xpvmin; |
embeddedartists | 0:4977187e90c7 | 271 | x2 = x2 + win->xpvmin; |
embeddedartists | 0:4977187e90c7 | 272 | y1 = y1 + win->ypvmin; |
embeddedartists | 0:4977187e90c7 | 273 | y2 = y2 + win->ypvmin; |
embeddedartists | 0:4977187e90c7 | 274 | |
embeddedartists | 0:4977187e90c7 | 275 | /* calculate delta_x and delta_y */ |
embeddedartists | 0:4977187e90c7 | 276 | dx = swim_abs(x2 - x1); |
embeddedartists | 0:4977187e90c7 | 277 | dy = swim_abs(y2 - y1); |
embeddedartists | 0:4977187e90c7 | 278 | |
embeddedartists | 0:4977187e90c7 | 279 | /* set the direction for the step for both x and y, and |
embeddedartists | 0:4977187e90c7 | 280 | initialize the error */ |
embeddedartists | 0:4977187e90c7 | 281 | if (x1 < x2) { |
embeddedartists | 0:4977187e90c7 | 282 | sx = 1; |
embeddedartists | 0:4977187e90c7 | 283 | } |
embeddedartists | 0:4977187e90c7 | 284 | else { |
embeddedartists | 0:4977187e90c7 | 285 | sx = -1; |
embeddedartists | 0:4977187e90c7 | 286 | } |
embeddedartists | 0:4977187e90c7 | 287 | |
embeddedartists | 0:4977187e90c7 | 288 | if (y1 < y2) { |
embeddedartists | 0:4977187e90c7 | 289 | sy = 1; |
embeddedartists | 0:4977187e90c7 | 290 | } |
embeddedartists | 0:4977187e90c7 | 291 | else { |
embeddedartists | 0:4977187e90c7 | 292 | sy = -1; |
embeddedartists | 0:4977187e90c7 | 293 | } |
embeddedartists | 0:4977187e90c7 | 294 | |
embeddedartists | 0:4977187e90c7 | 295 | err = dx - dy; |
embeddedartists | 0:4977187e90c7 | 296 | |
embeddedartists | 0:4977187e90c7 | 297 | while (1) { |
embeddedartists | 0:4977187e90c7 | 298 | if ((x1 >= win->xpvmin) && (x1 <= win->xpvmax) && |
embeddedartists | 0:4977187e90c7 | 299 | (y1 >= win->ypvmin) && (y1 <= win->ypvmax)) { |
embeddedartists | 0:4977187e90c7 | 300 | swim_put_pixel_physical(win, x1, y1, win->pen); |
embeddedartists | 0:4977187e90c7 | 301 | } |
embeddedartists | 0:4977187e90c7 | 302 | |
embeddedartists | 0:4977187e90c7 | 303 | if ((x1 == x2) && (y1 == y2)) { |
embeddedartists | 0:4977187e90c7 | 304 | return; |
embeddedartists | 0:4977187e90c7 | 305 | } |
embeddedartists | 0:4977187e90c7 | 306 | |
embeddedartists | 0:4977187e90c7 | 307 | e2 = 2 * err; |
embeddedartists | 0:4977187e90c7 | 308 | if (e2 > -dy) { |
embeddedartists | 0:4977187e90c7 | 309 | err -= dy; |
embeddedartists | 0:4977187e90c7 | 310 | x1 += sx; |
embeddedartists | 0:4977187e90c7 | 311 | } |
embeddedartists | 0:4977187e90c7 | 312 | if (e2 < dx) { |
embeddedartists | 0:4977187e90c7 | 313 | err += dx; |
embeddedartists | 0:4977187e90c7 | 314 | y1 += sy; |
embeddedartists | 0:4977187e90c7 | 315 | } |
embeddedartists | 0:4977187e90c7 | 316 | } |
embeddedartists | 0:4977187e90c7 | 317 | } |
embeddedartists | 0:4977187e90c7 | 318 | |
embeddedartists | 0:4977187e90c7 | 319 | /* Draw a diamond in the virtual window */ |
embeddedartists | 0:4977187e90c7 | 320 | void swim_put_diamond(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 321 | int32_t x, |
embeddedartists | 0:4977187e90c7 | 322 | int32_t y, |
embeddedartists | 0:4977187e90c7 | 323 | int32_t rx, |
embeddedartists | 0:4977187e90c7 | 324 | int32_t ry) |
embeddedartists | 0:4977187e90c7 | 325 | { |
embeddedartists | 0:4977187e90c7 | 326 | int32_t xleft, xright, xleft1, xleft2, xright1, idy, ypmid; |
embeddedartists | 0:4977187e90c7 | 327 | int32_t ypmin, ypmax, dlta, err, e2; |
embeddedartists | 0:4977187e90c7 | 328 | |
embeddedartists | 0:4977187e90c7 | 329 | /* Use line draw functions to draw border in pen color in virtual |
embeddedartists | 0:4977187e90c7 | 330 | coordinates */ |
embeddedartists | 0:4977187e90c7 | 331 | swim_put_line(win, x - rx, y, x, y - ry); |
embeddedartists | 0:4977187e90c7 | 332 | swim_put_line(win, x + rx, y, x, y - ry); |
embeddedartists | 0:4977187e90c7 | 333 | swim_put_line(win, x - rx, y, x, y + ry); |
embeddedartists | 0:4977187e90c7 | 334 | swim_put_line(win, x + rx, y, x, y + ry); |
embeddedartists | 0:4977187e90c7 | 335 | |
embeddedartists | 0:4977187e90c7 | 336 | /* Adjust rx and rx for interior fill region minus border */ |
embeddedartists | 0:4977187e90c7 | 337 | rx--; |
embeddedartists | 0:4977187e90c7 | 338 | ry--; |
embeddedartists | 0:4977187e90c7 | 339 | if ((rx <= 0) || (ry <= 0)) { |
embeddedartists | 0:4977187e90c7 | 340 | return; |
embeddedartists | 0:4977187e90c7 | 341 | } |
embeddedartists | 0:4977187e90c7 | 342 | |
embeddedartists | 0:4977187e90c7 | 343 | /* Y limits in physical coordinates minus border line */ |
embeddedartists | 0:4977187e90c7 | 344 | ypmin = y - ry + win->ypvmin; |
embeddedartists | 0:4977187e90c7 | 345 | ypmid = y + win->ypvmin; |
embeddedartists | 0:4977187e90c7 | 346 | ypmax = y + ry + win->ypvmin; |
embeddedartists | 0:4977187e90c7 | 347 | |
embeddedartists | 0:4977187e90c7 | 348 | /* X starts draw from center line */ |
embeddedartists | 0:4977187e90c7 | 349 | xleft = xright = x + win->xpvmin; |
embeddedartists | 0:4977187e90c7 | 350 | |
embeddedartists | 0:4977187e90c7 | 351 | err = rx - ry; |
embeddedartists | 0:4977187e90c7 | 352 | dlta = 1 + rx / ry; |
embeddedartists | 0:4977187e90c7 | 353 | |
embeddedartists | 0:4977187e90c7 | 354 | for (idy = ypmin; idy <= ypmid; idy++) { |
embeddedartists | 0:4977187e90c7 | 355 | xleft1 = xleft2 = xleft; |
embeddedartists | 0:4977187e90c7 | 356 | xright1 = xright; |
embeddedartists | 0:4977187e90c7 | 357 | |
embeddedartists | 0:4977187e90c7 | 358 | /* Clip left and right to virtual window size */ |
embeddedartists | 0:4977187e90c7 | 359 | if (xleft1 < win->xpvmin) { |
embeddedartists | 0:4977187e90c7 | 360 | xleft2 = xleft1 = win->xpvmin; |
embeddedartists | 0:4977187e90c7 | 361 | } |
embeddedartists | 0:4977187e90c7 | 362 | if (xright1 > win->xpvmax) { |
embeddedartists | 0:4977187e90c7 | 363 | xright1 = win->xpvmax; |
embeddedartists | 0:4977187e90c7 | 364 | } |
embeddedartists | 0:4977187e90c7 | 365 | |
embeddedartists | 0:4977187e90c7 | 366 | /* Is top half visible? */ |
embeddedartists | 0:4977187e90c7 | 367 | if ((idy >= win->ypvmin) && (idy <= win->ypvmax)) { |
embeddedartists | 0:4977187e90c7 | 368 | while (xleft1 <= xright1) { |
embeddedartists | 0:4977187e90c7 | 369 | swim_put_pixel_physical(win, xleft1, idy, win->fill); |
embeddedartists | 0:4977187e90c7 | 370 | xleft1++; |
embeddedartists | 0:4977187e90c7 | 371 | } |
embeddedartists | 0:4977187e90c7 | 372 | } |
embeddedartists | 0:4977187e90c7 | 373 | |
embeddedartists | 0:4977187e90c7 | 374 | /* Draw bottom half if visible */ |
embeddedartists | 0:4977187e90c7 | 375 | if ((ypmax >= ypmid) && (ypmax <= win->ypvmax)) { |
embeddedartists | 0:4977187e90c7 | 376 | /* Mirror bottom */ |
embeddedartists | 0:4977187e90c7 | 377 | while (xleft2 <= xright1) { |
embeddedartists | 0:4977187e90c7 | 378 | swim_put_pixel_physical(win, xleft2, ypmax, win->fill); |
embeddedartists | 0:4977187e90c7 | 379 | xleft2++; |
embeddedartists | 0:4977187e90c7 | 380 | } |
embeddedartists | 0:4977187e90c7 | 381 | } |
embeddedartists | 0:4977187e90c7 | 382 | ypmax--; |
embeddedartists | 0:4977187e90c7 | 383 | |
embeddedartists | 0:4977187e90c7 | 384 | e2 = 2 * err; |
embeddedartists | 0:4977187e90c7 | 385 | if (e2 > -ry) { |
embeddedartists | 0:4977187e90c7 | 386 | err -= ry; |
embeddedartists | 0:4977187e90c7 | 387 | xleft -= dlta; |
embeddedartists | 0:4977187e90c7 | 388 | xright += dlta; |
embeddedartists | 0:4977187e90c7 | 389 | } |
embeddedartists | 0:4977187e90c7 | 390 | if (e2 < rx) { |
embeddedartists | 0:4977187e90c7 | 391 | err += rx; |
embeddedartists | 0:4977187e90c7 | 392 | } |
embeddedartists | 0:4977187e90c7 | 393 | } |
embeddedartists | 0:4977187e90c7 | 394 | } |
embeddedartists | 0:4977187e90c7 | 395 | |
embeddedartists | 0:4977187e90c7 | 396 | /* Draws a circle in the virtual window */ |
embeddedartists | 0:4977187e90c7 | 397 | void swim_put_circle(SWIM_WINDOW_T *win, int32_t cx, int32_t cy, int32_t radius, int32_t Filled) |
embeddedartists | 0:4977187e90c7 | 398 | { |
embeddedartists | 0:4977187e90c7 | 399 | int32_t Error = -radius; |
embeddedartists | 0:4977187e90c7 | 400 | int16_t x = radius; |
embeddedartists | 0:4977187e90c7 | 401 | int16_t y = 0; |
embeddedartists | 0:4977187e90c7 | 402 | |
embeddedartists | 0:4977187e90c7 | 403 | /* Convert virtual coordinates to physical coordinates */ |
embeddedartists | 0:4977187e90c7 | 404 | cx += win->xpvmin; |
embeddedartists | 0:4977187e90c7 | 405 | cy += win->ypvmin; |
embeddedartists | 0:4977187e90c7 | 406 | |
embeddedartists | 0:4977187e90c7 | 407 | while ( x >= y ) { |
embeddedartists | 0:4977187e90c7 | 408 | swim_plot8points(win, cx, cy, x, y, Filled); |
embeddedartists | 0:4977187e90c7 | 409 | |
embeddedartists | 0:4977187e90c7 | 410 | Error += y; |
embeddedartists | 0:4977187e90c7 | 411 | ++y; |
embeddedartists | 0:4977187e90c7 | 412 | Error += y; |
embeddedartists | 0:4977187e90c7 | 413 | |
embeddedartists | 0:4977187e90c7 | 414 | if ( Error >= 0 ) { |
embeddedartists | 0:4977187e90c7 | 415 | --x; |
embeddedartists | 0:4977187e90c7 | 416 | Error -= x; |
embeddedartists | 0:4977187e90c7 | 417 | Error -= x; |
embeddedartists | 0:4977187e90c7 | 418 | } |
embeddedartists | 0:4977187e90c7 | 419 | } |
embeddedartists | 0:4977187e90c7 | 420 | } |
embeddedartists | 0:4977187e90c7 | 421 | |
embeddedartists | 0:4977187e90c7 | 422 | /* Fills the draw area of the display with the selected color */ |
embeddedartists | 0:4977187e90c7 | 423 | void swim_clear_screen(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 424 | COLOR_T colr) |
embeddedartists | 0:4977187e90c7 | 425 | { |
embeddedartists | 0:4977187e90c7 | 426 | int32_t x, y; |
embeddedartists | 0:4977187e90c7 | 427 | |
embeddedartists | 0:4977187e90c7 | 428 | for (y = win->ypvmin; y <= win->ypvmax; y++) { |
embeddedartists | 0:4977187e90c7 | 429 | for (x = win->xpvmin; x <= win->xpvmax; x++) { |
embeddedartists | 0:4977187e90c7 | 430 | swim_put_pixel_physical(win, x, y, colr); |
embeddedartists | 0:4977187e90c7 | 431 | } |
embeddedartists | 0:4977187e90c7 | 432 | } |
embeddedartists | 0:4977187e90c7 | 433 | } |
embeddedartists | 0:4977187e90c7 | 434 | |
embeddedartists | 0:4977187e90c7 | 435 | /* Place a box with corners (X1, Y1) and (X2, Y2) */ |
embeddedartists | 0:4977187e90c7 | 436 | void swim_put_box(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 437 | int32_t x1, |
embeddedartists | 0:4977187e90c7 | 438 | int32_t y1, |
embeddedartists | 0:4977187e90c7 | 439 | int32_t x2, |
embeddedartists | 0:4977187e90c7 | 440 | int32_t y2) |
embeddedartists | 0:4977187e90c7 | 441 | { |
embeddedartists | 0:4977187e90c7 | 442 | int32_t xinc, yinc; |
embeddedartists | 0:4977187e90c7 | 443 | int32_t ysave; |
embeddedartists | 0:4977187e90c7 | 444 | |
embeddedartists | 0:4977187e90c7 | 445 | if (x1 > x2) { |
embeddedartists | 0:4977187e90c7 | 446 | xinc = x1; |
embeddedartists | 0:4977187e90c7 | 447 | x1 = x2; |
embeddedartists | 0:4977187e90c7 | 448 | x2 = xinc; |
embeddedartists | 0:4977187e90c7 | 449 | } |
embeddedartists | 0:4977187e90c7 | 450 | |
embeddedartists | 0:4977187e90c7 | 451 | /* Swap y1 and y2 if y1 is larger than y2 */ |
embeddedartists | 0:4977187e90c7 | 452 | if (y1 > y2) { |
embeddedartists | 0:4977187e90c7 | 453 | yinc = y1; |
embeddedartists | 0:4977187e90c7 | 454 | y1 = y2; |
embeddedartists | 0:4977187e90c7 | 455 | y2 = yinc; |
embeddedartists | 0:4977187e90c7 | 456 | } |
embeddedartists | 0:4977187e90c7 | 457 | |
embeddedartists | 0:4977187e90c7 | 458 | /* Convert virtual coordinates to physical coordinates */ |
embeddedartists | 0:4977187e90c7 | 459 | x1 = x1 + win->xpvmin; |
embeddedartists | 0:4977187e90c7 | 460 | x2 = x2 + win->xpvmin; |
embeddedartists | 0:4977187e90c7 | 461 | y1 = y1 + win->ypvmin; |
embeddedartists | 0:4977187e90c7 | 462 | y2 = y2 + win->ypvmin; |
embeddedartists | 0:4977187e90c7 | 463 | |
embeddedartists | 0:4977187e90c7 | 464 | /* Clip boxes to window sizes */ |
embeddedartists | 0:4977187e90c7 | 465 | if (x1 < win->xpvmin) { |
embeddedartists | 0:4977187e90c7 | 466 | x1 = win->xpvmin; |
embeddedartists | 0:4977187e90c7 | 467 | } |
embeddedartists | 0:4977187e90c7 | 468 | if (y1 < win->ypvmin) { |
embeddedartists | 0:4977187e90c7 | 469 | y1 = win->ypvmin; |
embeddedartists | 0:4977187e90c7 | 470 | } |
embeddedartists | 0:4977187e90c7 | 471 | if (x2 > win->xpvmax) { |
embeddedartists | 0:4977187e90c7 | 472 | x2 = win->xpvmax; |
embeddedartists | 0:4977187e90c7 | 473 | } |
embeddedartists | 0:4977187e90c7 | 474 | if (y2 > win->ypvmax) { |
embeddedartists | 0:4977187e90c7 | 475 | y2 = win->ypvmax; |
embeddedartists | 0:4977187e90c7 | 476 | } |
embeddedartists | 0:4977187e90c7 | 477 | |
embeddedartists | 0:4977187e90c7 | 478 | /* Get X and Y differences */ |
embeddedartists | 0:4977187e90c7 | 479 | xinc = x2 - x1; |
embeddedartists | 0:4977187e90c7 | 480 | yinc = y2 - y1; |
embeddedartists | 0:4977187e90c7 | 481 | |
embeddedartists | 0:4977187e90c7 | 482 | /* Make outer edge of box in pen color */ |
embeddedartists | 0:4977187e90c7 | 483 | swim_put_line_raw(win, x1, y1, x2, y1); |
embeddedartists | 0:4977187e90c7 | 484 | swim_put_line_raw(win, x2, y1, x2, y2); |
embeddedartists | 0:4977187e90c7 | 485 | swim_put_line_raw(win, x2, y2, x1, y2); |
embeddedartists | 0:4977187e90c7 | 486 | swim_put_line_raw(win, x1, y2, x1, y1); |
embeddedartists | 0:4977187e90c7 | 487 | |
embeddedartists | 0:4977187e90c7 | 488 | /* Increment X, Y values so they won't overwrite the edge */ |
embeddedartists | 0:4977187e90c7 | 489 | x1++; |
embeddedartists | 0:4977187e90c7 | 490 | y1++; |
embeddedartists | 0:4977187e90c7 | 491 | |
embeddedartists | 0:4977187e90c7 | 492 | /* Draw the box inside with the fill color */ |
embeddedartists | 0:4977187e90c7 | 493 | ysave = y1; |
embeddedartists | 0:4977187e90c7 | 494 | while (x1 < x2) { |
embeddedartists | 0:4977187e90c7 | 495 | y1 = ysave; |
embeddedartists | 0:4977187e90c7 | 496 | while (y1 < y2) { |
embeddedartists | 0:4977187e90c7 | 497 | swim_put_pixel_physical(win, x1, y1, win->fill); |
embeddedartists | 0:4977187e90c7 | 498 | y1++; |
embeddedartists | 0:4977187e90c7 | 499 | } |
embeddedartists | 0:4977187e90c7 | 500 | |
embeddedartists | 0:4977187e90c7 | 501 | x1++; |
embeddedartists | 0:4977187e90c7 | 502 | } |
embeddedartists | 0:4977187e90c7 | 503 | } |
embeddedartists | 0:4977187e90c7 | 504 | |
embeddedartists | 0:4977187e90c7 | 505 | /* Initializes a window and the default values for the window */ |
embeddedartists | 0:4977187e90c7 | 506 | BOOL_32 swim_window_open(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 507 | int32_t xsize, |
embeddedartists | 0:4977187e90c7 | 508 | int32_t ysize, |
embeddedartists | 0:4977187e90c7 | 509 | COLOR_T *fbaddr, |
embeddedartists | 0:4977187e90c7 | 510 | int32_t xwin_min, |
embeddedartists | 0:4977187e90c7 | 511 | int32_t ywin_min, |
embeddedartists | 0:4977187e90c7 | 512 | int32_t xwin_max, |
embeddedartists | 0:4977187e90c7 | 513 | int32_t ywin_max, |
embeddedartists | 0:4977187e90c7 | 514 | int32_t border_width, |
embeddedartists | 0:4977187e90c7 | 515 | COLOR_T pcolor, |
embeddedartists | 0:4977187e90c7 | 516 | COLOR_T bkcolor, |
embeddedartists | 0:4977187e90c7 | 517 | COLOR_T fcolor) |
embeddedartists | 0:4977187e90c7 | 518 | { |
embeddedartists | 0:4977187e90c7 | 519 | BOOL_32 init; |
embeddedartists | 0:4977187e90c7 | 520 | |
embeddedartists | 0:4977187e90c7 | 521 | init = swim_window_open_p(win, xsize, ysize, fbaddr, xwin_min, |
embeddedartists | 0:4977187e90c7 | 522 | ywin_min, xwin_max, ywin_max, border_width, pcolor, bkcolor, |
embeddedartists | 0:4977187e90c7 | 523 | fcolor, true); |
embeddedartists | 0:4977187e90c7 | 524 | |
embeddedartists | 0:4977187e90c7 | 525 | /* Default font background is not transparent */ |
embeddedartists | 0:4977187e90c7 | 526 | win->tfont = 1; |
embeddedartists | 0:4977187e90c7 | 527 | |
embeddedartists | 0:4977187e90c7 | 528 | return init; |
embeddedartists | 0:4977187e90c7 | 529 | } |
embeddedartists | 0:4977187e90c7 | 530 | |
embeddedartists | 0:4977187e90c7 | 531 | /* Initializes a window without clearing it */ |
embeddedartists | 0:4977187e90c7 | 532 | BOOL_32 swim_window_open_noclear(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 533 | int32_t xsize, |
embeddedartists | 0:4977187e90c7 | 534 | int32_t ysize, |
embeddedartists | 0:4977187e90c7 | 535 | COLOR_T *fbaddr, |
embeddedartists | 0:4977187e90c7 | 536 | int32_t xwin_min, |
embeddedartists | 0:4977187e90c7 | 537 | int32_t ywin_min, |
embeddedartists | 0:4977187e90c7 | 538 | int32_t xwin_max, |
embeddedartists | 0:4977187e90c7 | 539 | int32_t ywin_max, |
embeddedartists | 0:4977187e90c7 | 540 | int32_t border_width, |
embeddedartists | 0:4977187e90c7 | 541 | COLOR_T pcolor, |
embeddedartists | 0:4977187e90c7 | 542 | COLOR_T bkcolor, |
embeddedartists | 0:4977187e90c7 | 543 | COLOR_T fcolor) |
embeddedartists | 0:4977187e90c7 | 544 | { |
embeddedartists | 0:4977187e90c7 | 545 | BOOL_32 init; |
embeddedartists | 0:4977187e90c7 | 546 | |
embeddedartists | 0:4977187e90c7 | 547 | init = swim_window_open_p(win, xsize, ysize, fbaddr, xwin_min, |
embeddedartists | 0:4977187e90c7 | 548 | ywin_min, xwin_max, ywin_max, border_width, pcolor, bkcolor, |
embeddedartists | 0:4977187e90c7 | 549 | fcolor, false); |
embeddedartists | 0:4977187e90c7 | 550 | |
embeddedartists | 0:4977187e90c7 | 551 | /* Default font background is transparent */ |
embeddedartists | 0:4977187e90c7 | 552 | win->tfont = 0; |
embeddedartists | 0:4977187e90c7 | 553 | |
embeddedartists | 0:4977187e90c7 | 554 | return init; |
embeddedartists | 0:4977187e90c7 | 555 | } |
embeddedartists | 0:4977187e90c7 | 556 | |
embeddedartists | 0:4977187e90c7 | 557 | /* Deallocates a window */ |
embeddedartists | 0:4977187e90c7 | 558 | void swim_window_close(SWIM_WINDOW_T *win) |
embeddedartists | 0:4977187e90c7 | 559 | { |
embeddedartists | 0:4977187e90c7 | 560 | win->winused = 0x0; |
embeddedartists | 0:4977187e90c7 | 561 | } |
embeddedartists | 0:4977187e90c7 | 562 | |
embeddedartists | 0:4977187e90c7 | 563 | /* Sets the pen color */ |
embeddedartists | 0:4977187e90c7 | 564 | void swim_set_pen_color(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 565 | COLOR_T pen_color) |
embeddedartists | 0:4977187e90c7 | 566 | { |
embeddedartists | 0:4977187e90c7 | 567 | win->pen = pen_color; |
embeddedartists | 0:4977187e90c7 | 568 | } |
embeddedartists | 0:4977187e90c7 | 569 | |
embeddedartists | 0:4977187e90c7 | 570 | /* Sets the fill color */ |
embeddedartists | 0:4977187e90c7 | 571 | void swim_set_fill_color(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 572 | COLOR_T fill_color) |
embeddedartists | 0:4977187e90c7 | 573 | { |
embeddedartists | 0:4977187e90c7 | 574 | win->fill = fill_color; |
embeddedartists | 0:4977187e90c7 | 575 | } |
embeddedartists | 0:4977187e90c7 | 576 | |
embeddedartists | 0:4977187e90c7 | 577 | /* Sets the color used for backgrounds */ |
embeddedartists | 0:4977187e90c7 | 578 | void swim_set_bkg_color(SWIM_WINDOW_T *win, |
embeddedartists | 0:4977187e90c7 | 579 | COLOR_T bkg_color) |
embeddedartists | 0:4977187e90c7 | 580 | { |
embeddedartists | 0:4977187e90c7 | 581 | win->bkg = bkg_color; |
embeddedartists | 0:4977187e90c7 | 582 | } |
embeddedartists | 0:4977187e90c7 | 583 | |
embeddedartists | 17:6e2abf107800 | 584 | /* Sets the font to be used for all new windows */ |
embeddedartists | 17:6e2abf107800 | 585 | void swim_set_default_font(const FONT_T* def_font) |
embeddedartists | 17:6e2abf107800 | 586 | { |
embeddedartists | 17:6e2abf107800 | 587 | defaultFont = def_font; |
embeddedartists | 17:6e2abf107800 | 588 | } |
embeddedartists | 17:6e2abf107800 | 589 | |
embeddedartists | 0:4977187e90c7 | 590 | /* Get the virtual window horizontal size */ |
embeddedartists | 0:4977187e90c7 | 591 | int32_t swim_get_horizontal_size(SWIM_WINDOW_T *win) |
embeddedartists | 0:4977187e90c7 | 592 | { |
embeddedartists | 0:4977187e90c7 | 593 | return win->xvsize; |
embeddedartists | 0:4977187e90c7 | 594 | } |
embeddedartists | 0:4977187e90c7 | 595 | |
embeddedartists | 0:4977187e90c7 | 596 | /* Get the virtual window vertical size */ |
embeddedartists | 0:4977187e90c7 | 597 | int32_t swim_get_vertical_size(SWIM_WINDOW_T *win) |
embeddedartists | 0:4977187e90c7 | 598 | { |
embeddedartists | 0:4977187e90c7 | 599 | return win->yvsize; |
embeddedartists | 0:4977187e90c7 | 600 | } |
embeddedartists | 0:4977187e90c7 | 601 |