Displays distance to start location on OLED screen.

Dependencies:   mbed

Committer:
iforce2d
Date:
Wed Mar 07 12:49:14 2018 +0000
Revision:
0:972874f31c98
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
iforce2d 0:972874f31c98 1 /*
iforce2d 0:972874f31c98 2
iforce2d 0:972874f31c98 3 u8g_ellipse.c
iforce2d 0:972874f31c98 4
iforce2d 0:972874f31c98 5 Utility to draw empty and filled ellipses.
iforce2d 0:972874f31c98 6
iforce2d 0:972874f31c98 7 Universal 8bit Graphics Library
iforce2d 0:972874f31c98 8
iforce2d 0:972874f31c98 9 Copyright (c) 2011, bjthom@gmail.com
iforce2d 0:972874f31c98 10 All rights reserved.
iforce2d 0:972874f31c98 11
iforce2d 0:972874f31c98 12 Redistribution and use in source and binary forms, with or without modification,
iforce2d 0:972874f31c98 13 are permitted provided that the following conditions are met:
iforce2d 0:972874f31c98 14
iforce2d 0:972874f31c98 15 * Redistributions of source code must retain the above copyright notice, this list
iforce2d 0:972874f31c98 16 of conditions and the following disclaimer.
iforce2d 0:972874f31c98 17
iforce2d 0:972874f31c98 18 * Redistributions in binary form must reproduce the above copyright notice, this
iforce2d 0:972874f31c98 19 list of conditions and the following disclaimer in the documentation and/or other
iforce2d 0:972874f31c98 20 materials provided with the distribution.
iforce2d 0:972874f31c98 21
iforce2d 0:972874f31c98 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
iforce2d 0:972874f31c98 23 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
iforce2d 0:972874f31c98 24 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
iforce2d 0:972874f31c98 25 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
iforce2d 0:972874f31c98 26 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
iforce2d 0:972874f31c98 27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
iforce2d 0:972874f31c98 28 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
iforce2d 0:972874f31c98 29 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
iforce2d 0:972874f31c98 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
iforce2d 0:972874f31c98 31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
iforce2d 0:972874f31c98 32 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
iforce2d 0:972874f31c98 33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
iforce2d 0:972874f31c98 34 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
iforce2d 0:972874f31c98 35
iforce2d 0:972874f31c98 36 Addition to the U8G Library as of 02/29/12
iforce2d 0:972874f31c98 37 Adapted from Bresenham's Algorithm and the following websites:
iforce2d 0:972874f31c98 38 http://free.pages.at/easyfilter/bresenham.html
iforce2d 0:972874f31c98 39 http://homepage.smc.edu/kennedy_john/belipse.pdf
iforce2d 0:972874f31c98 40
iforce2d 0:972874f31c98 41 */
iforce2d 0:972874f31c98 42
iforce2d 0:972874f31c98 43 #include "u8g.h"
iforce2d 0:972874f31c98 44
iforce2d 0:972874f31c98 45
iforce2d 0:972874f31c98 46 #ifdef WORK_IN_PROGRESS
iforce2d 0:972874f31c98 47
iforce2d 0:972874f31c98 48 void u8g_DrawEllipseRect(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t x1, u8g_uint_t y1)
iforce2d 0:972874f31c98 49 {
iforce2d 0:972874f31c98 50 int a = abs(x1 - x0);
iforce2d 0:972874f31c98 51 int b = abs(y1 - y0); //get diameters
iforce2d 0:972874f31c98 52 int b1 = b&1;
iforce2d 0:972874f31c98 53 long dx = 4*(1-a)*b*b;
iforce2d 0:972874f31c98 54 long dy = 4*(b1+1)*a*a;
iforce2d 0:972874f31c98 55 long err = dx+dy+b1*a*a;
iforce2d 0:972874f31c98 56 long e2;
iforce2d 0:972874f31c98 57
iforce2d 0:972874f31c98 58 if (x0 > x1) { x0 = x1; x1 += a; }
iforce2d 0:972874f31c98 59 if (y0 > y1) { y0 = y1; }
iforce2d 0:972874f31c98 60 y0 += (b+1)/2;
iforce2d 0:972874f31c98 61 y1 = y0-b1;
iforce2d 0:972874f31c98 62 a *= 8*a;
iforce2d 0:972874f31c98 63 b1 = 8*b*b;
iforce2d 0:972874f31c98 64
iforce2d 0:972874f31c98 65 do {
iforce2d 0:972874f31c98 66 u8g_DrawPixel(u8g, x1, y0);
iforce2d 0:972874f31c98 67 u8g_DrawPixel(u8g, x0, y0);
iforce2d 0:972874f31c98 68 u8g_DrawPixel(u8g, x0, y1);
iforce2d 0:972874f31c98 69 u8g_DrawPixel(u8g, x1, y1);
iforce2d 0:972874f31c98 70 e2 = 2*err;
iforce2d 0:972874f31c98 71 if (e2 >= dx) {
iforce2d 0:972874f31c98 72 x0++;
iforce2d 0:972874f31c98 73 x1--;
iforce2d 0:972874f31c98 74 err += dx += b1;
iforce2d 0:972874f31c98 75 }
iforce2d 0:972874f31c98 76 if (e2 <= dy) {
iforce2d 0:972874f31c98 77 y0++;
iforce2d 0:972874f31c98 78 y1--;
iforce2d 0:972874f31c98 79 err += dy += a;
iforce2d 0:972874f31c98 80 }
iforce2d 0:972874f31c98 81 } while (x0 <= x1);
iforce2d 0:972874f31c98 82
iforce2d 0:972874f31c98 83 while (y0-y1 < b) {
iforce2d 0:972874f31c98 84 u8g_DrawPixel(u8g, x0-1, y0);
iforce2d 0:972874f31c98 85 u8g_DrawPixel(u8g, x1+1, y0++);
iforce2d 0:972874f31c98 86 u8g_DrawPixel(u8g, x0-1, y1);
iforce2d 0:972874f31c98 87 u8g_DrawPixel(u8g, x1+1, y1--);
iforce2d 0:972874f31c98 88 }
iforce2d 0:972874f31c98 89 }
iforce2d 0:972874f31c98 90
iforce2d 0:972874f31c98 91 void u8g_DrawEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t xr, u8g_uint_t yr)
iforce2d 0:972874f31c98 92 {
iforce2d 0:972874f31c98 93 u8g_DrawPixel(u8g, x0, y0+yr);
iforce2d 0:972874f31c98 94 u8g_DrawPixel(u8g, x0, y0-yr);
iforce2d 0:972874f31c98 95 u8g_DrawPixel(u8g, x0+xr, y0);
iforce2d 0:972874f31c98 96 u8g_DrawPixel(u8g, x0-xr, y0);
iforce2d 0:972874f31c98 97 }
iforce2d 0:972874f31c98 98
iforce2d 0:972874f31c98 99 #endif
iforce2d 0:972874f31c98 100
iforce2d 0:972874f31c98 101 #if defined(U8G_16BIT)
iforce2d 0:972874f31c98 102 typedef int32_t u8g_long_t;
iforce2d 0:972874f31c98 103 #else
iforce2d 0:972874f31c98 104 typedef int16_t u8g_long_t;
iforce2d 0:972874f31c98 105 #endif
iforce2d 0:972874f31c98 106
iforce2d 0:972874f31c98 107
iforce2d 0:972874f31c98 108 /*
iforce2d 0:972874f31c98 109 Source:
iforce2d 0:972874f31c98 110 ftp://pc.fk0.name/pub/books/programming/bezier-ellipse.pdf
iforce2d 0:972874f31c98 111 Foley, Computer Graphics, p 90
iforce2d 0:972874f31c98 112 */
iforce2d 0:972874f31c98 113 static void u8g_draw_ellipse_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option) U8G_NOINLINE;
iforce2d 0:972874f31c98 114 static void u8g_draw_ellipse_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option)
iforce2d 0:972874f31c98 115 {
iforce2d 0:972874f31c98 116 /* upper right */
iforce2d 0:972874f31c98 117 if ( option & U8G_DRAW_UPPER_RIGHT )
iforce2d 0:972874f31c98 118 {
iforce2d 0:972874f31c98 119 u8g_DrawPixel(u8g, x0 + x, y0 - y);
iforce2d 0:972874f31c98 120 }
iforce2d 0:972874f31c98 121
iforce2d 0:972874f31c98 122 /* upper left */
iforce2d 0:972874f31c98 123 if ( option & U8G_DRAW_UPPER_LEFT )
iforce2d 0:972874f31c98 124 {
iforce2d 0:972874f31c98 125 u8g_DrawPixel(u8g, x0 - x, y0 - y);
iforce2d 0:972874f31c98 126 }
iforce2d 0:972874f31c98 127
iforce2d 0:972874f31c98 128 /* lower right */
iforce2d 0:972874f31c98 129 if ( option & U8G_DRAW_LOWER_RIGHT )
iforce2d 0:972874f31c98 130 {
iforce2d 0:972874f31c98 131 u8g_DrawPixel(u8g, x0 + x, y0 + y);
iforce2d 0:972874f31c98 132 }
iforce2d 0:972874f31c98 133
iforce2d 0:972874f31c98 134 /* lower left */
iforce2d 0:972874f31c98 135 if ( option & U8G_DRAW_LOWER_LEFT )
iforce2d 0:972874f31c98 136 {
iforce2d 0:972874f31c98 137 u8g_DrawPixel(u8g, x0 - x, y0 + y);
iforce2d 0:972874f31c98 138 }
iforce2d 0:972874f31c98 139 }
iforce2d 0:972874f31c98 140
iforce2d 0:972874f31c98 141 void u8g_draw_ellipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option)
iforce2d 0:972874f31c98 142 {
iforce2d 0:972874f31c98 143 u8g_uint_t x, y;
iforce2d 0:972874f31c98 144 u8g_long_t xchg, ychg;
iforce2d 0:972874f31c98 145 u8g_long_t err;
iforce2d 0:972874f31c98 146 u8g_long_t rxrx2;
iforce2d 0:972874f31c98 147 u8g_long_t ryry2;
iforce2d 0:972874f31c98 148 u8g_long_t stopx, stopy;
iforce2d 0:972874f31c98 149
iforce2d 0:972874f31c98 150 rxrx2 = rx;
iforce2d 0:972874f31c98 151 rxrx2 *= rx;
iforce2d 0:972874f31c98 152 rxrx2 *= 2;
iforce2d 0:972874f31c98 153
iforce2d 0:972874f31c98 154 ryry2 = ry;
iforce2d 0:972874f31c98 155 ryry2 *= ry;
iforce2d 0:972874f31c98 156 ryry2 *= 2;
iforce2d 0:972874f31c98 157
iforce2d 0:972874f31c98 158 x = rx;
iforce2d 0:972874f31c98 159 y = 0;
iforce2d 0:972874f31c98 160
iforce2d 0:972874f31c98 161 xchg = 1;
iforce2d 0:972874f31c98 162 xchg -= rx;
iforce2d 0:972874f31c98 163 xchg -= rx;
iforce2d 0:972874f31c98 164 xchg *= ry;
iforce2d 0:972874f31c98 165 xchg *= ry;
iforce2d 0:972874f31c98 166
iforce2d 0:972874f31c98 167 ychg = rx;
iforce2d 0:972874f31c98 168 ychg *= rx;
iforce2d 0:972874f31c98 169
iforce2d 0:972874f31c98 170 err = 0;
iforce2d 0:972874f31c98 171
iforce2d 0:972874f31c98 172 stopx = ryry2;
iforce2d 0:972874f31c98 173 stopx *= rx;
iforce2d 0:972874f31c98 174 stopy = 0;
iforce2d 0:972874f31c98 175
iforce2d 0:972874f31c98 176 while( stopx >= stopy )
iforce2d 0:972874f31c98 177 {
iforce2d 0:972874f31c98 178 u8g_draw_ellipse_section(u8g, x, y, x0, y0, option);
iforce2d 0:972874f31c98 179 y++;
iforce2d 0:972874f31c98 180 stopy += rxrx2;
iforce2d 0:972874f31c98 181 err += ychg;
iforce2d 0:972874f31c98 182 ychg += rxrx2;
iforce2d 0:972874f31c98 183 if ( 2*err+xchg > 0 )
iforce2d 0:972874f31c98 184 {
iforce2d 0:972874f31c98 185 x--;
iforce2d 0:972874f31c98 186 stopx -= ryry2;
iforce2d 0:972874f31c98 187 err += xchg;
iforce2d 0:972874f31c98 188 xchg += ryry2;
iforce2d 0:972874f31c98 189 }
iforce2d 0:972874f31c98 190 }
iforce2d 0:972874f31c98 191
iforce2d 0:972874f31c98 192 x = 0;
iforce2d 0:972874f31c98 193 y = ry;
iforce2d 0:972874f31c98 194
iforce2d 0:972874f31c98 195 xchg = ry;
iforce2d 0:972874f31c98 196 xchg *= ry;
iforce2d 0:972874f31c98 197
iforce2d 0:972874f31c98 198 ychg = 1;
iforce2d 0:972874f31c98 199 ychg -= ry;
iforce2d 0:972874f31c98 200 ychg -= ry;
iforce2d 0:972874f31c98 201 ychg *= rx;
iforce2d 0:972874f31c98 202 ychg *= rx;
iforce2d 0:972874f31c98 203
iforce2d 0:972874f31c98 204 err = 0;
iforce2d 0:972874f31c98 205
iforce2d 0:972874f31c98 206 stopx = 0;
iforce2d 0:972874f31c98 207
iforce2d 0:972874f31c98 208 stopy = rxrx2;
iforce2d 0:972874f31c98 209 stopy *= ry;
iforce2d 0:972874f31c98 210
iforce2d 0:972874f31c98 211
iforce2d 0:972874f31c98 212 while( stopx <= stopy )
iforce2d 0:972874f31c98 213 {
iforce2d 0:972874f31c98 214 u8g_draw_ellipse_section(u8g, x, y, x0, y0, option);
iforce2d 0:972874f31c98 215 x++;
iforce2d 0:972874f31c98 216 stopx += ryry2;
iforce2d 0:972874f31c98 217 err += xchg;
iforce2d 0:972874f31c98 218 xchg += ryry2;
iforce2d 0:972874f31c98 219 if ( 2*err+ychg > 0 )
iforce2d 0:972874f31c98 220 {
iforce2d 0:972874f31c98 221 y--;
iforce2d 0:972874f31c98 222 stopy -= rxrx2;
iforce2d 0:972874f31c98 223 err += ychg;
iforce2d 0:972874f31c98 224 ychg += rxrx2;
iforce2d 0:972874f31c98 225 }
iforce2d 0:972874f31c98 226 }
iforce2d 0:972874f31c98 227
iforce2d 0:972874f31c98 228 }
iforce2d 0:972874f31c98 229
iforce2d 0:972874f31c98 230 void u8g_DrawEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option)
iforce2d 0:972874f31c98 231 {
iforce2d 0:972874f31c98 232 /* check for bounding box */
iforce2d 0:972874f31c98 233 {
iforce2d 0:972874f31c98 234 u8g_uint_t rxp, rxp2;
iforce2d 0:972874f31c98 235 u8g_uint_t ryp, ryp2;
iforce2d 0:972874f31c98 236
iforce2d 0:972874f31c98 237 rxp = rx;
iforce2d 0:972874f31c98 238 rxp++;
iforce2d 0:972874f31c98 239 rxp2 = rxp;
iforce2d 0:972874f31c98 240 rxp2 *= 2;
iforce2d 0:972874f31c98 241
iforce2d 0:972874f31c98 242 ryp = ry;
iforce2d 0:972874f31c98 243 ryp++;
iforce2d 0:972874f31c98 244 ryp2 = ryp;
iforce2d 0:972874f31c98 245 ryp2 *= 2;
iforce2d 0:972874f31c98 246
iforce2d 0:972874f31c98 247 if ( u8g_IsBBXIntersection(u8g, x0-rxp, y0-ryp, rxp2, ryp2) == 0)
iforce2d 0:972874f31c98 248 return;
iforce2d 0:972874f31c98 249 }
iforce2d 0:972874f31c98 250
iforce2d 0:972874f31c98 251 u8g_draw_ellipse(u8g, x0, y0, rx, ry, option);
iforce2d 0:972874f31c98 252 }
iforce2d 0:972874f31c98 253
iforce2d 0:972874f31c98 254 static void u8g_draw_filled_ellipse_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option) U8G_NOINLINE;
iforce2d 0:972874f31c98 255 static void u8g_draw_filled_ellipse_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option)
iforce2d 0:972874f31c98 256 {
iforce2d 0:972874f31c98 257 /* upper right */
iforce2d 0:972874f31c98 258 if ( option & U8G_DRAW_UPPER_RIGHT )
iforce2d 0:972874f31c98 259 {
iforce2d 0:972874f31c98 260 u8g_DrawVLine(u8g, x0+x, y0-y, y+1);
iforce2d 0:972874f31c98 261 }
iforce2d 0:972874f31c98 262
iforce2d 0:972874f31c98 263 /* upper left */
iforce2d 0:972874f31c98 264 if ( option & U8G_DRAW_UPPER_LEFT )
iforce2d 0:972874f31c98 265 {
iforce2d 0:972874f31c98 266 u8g_DrawVLine(u8g, x0-x, y0-y, y+1);
iforce2d 0:972874f31c98 267 }
iforce2d 0:972874f31c98 268
iforce2d 0:972874f31c98 269 /* lower right */
iforce2d 0:972874f31c98 270 if ( option & U8G_DRAW_LOWER_RIGHT )
iforce2d 0:972874f31c98 271 {
iforce2d 0:972874f31c98 272 u8g_DrawVLine(u8g, x0+x, y0, y+1);
iforce2d 0:972874f31c98 273 }
iforce2d 0:972874f31c98 274
iforce2d 0:972874f31c98 275 /* lower left */
iforce2d 0:972874f31c98 276 if ( option & U8G_DRAW_LOWER_LEFT )
iforce2d 0:972874f31c98 277 {
iforce2d 0:972874f31c98 278 u8g_DrawVLine(u8g, x0-x, y0, y+1);
iforce2d 0:972874f31c98 279 }
iforce2d 0:972874f31c98 280 }
iforce2d 0:972874f31c98 281
iforce2d 0:972874f31c98 282 void u8g_draw_filled_ellipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option)
iforce2d 0:972874f31c98 283 {
iforce2d 0:972874f31c98 284 u8g_uint_t x, y;
iforce2d 0:972874f31c98 285 u8g_long_t xchg, ychg;
iforce2d 0:972874f31c98 286 u8g_long_t err;
iforce2d 0:972874f31c98 287 u8g_long_t rxrx2;
iforce2d 0:972874f31c98 288 u8g_long_t ryry2;
iforce2d 0:972874f31c98 289 u8g_long_t stopx, stopy;
iforce2d 0:972874f31c98 290
iforce2d 0:972874f31c98 291 rxrx2 = rx;
iforce2d 0:972874f31c98 292 rxrx2 *= rx;
iforce2d 0:972874f31c98 293 rxrx2 *= 2;
iforce2d 0:972874f31c98 294
iforce2d 0:972874f31c98 295 ryry2 = ry;
iforce2d 0:972874f31c98 296 ryry2 *= ry;
iforce2d 0:972874f31c98 297 ryry2 *= 2;
iforce2d 0:972874f31c98 298
iforce2d 0:972874f31c98 299 x = rx;
iforce2d 0:972874f31c98 300 y = 0;
iforce2d 0:972874f31c98 301
iforce2d 0:972874f31c98 302 xchg = 1;
iforce2d 0:972874f31c98 303 xchg -= rx;
iforce2d 0:972874f31c98 304 xchg -= rx;
iforce2d 0:972874f31c98 305 xchg *= ry;
iforce2d 0:972874f31c98 306 xchg *= ry;
iforce2d 0:972874f31c98 307
iforce2d 0:972874f31c98 308 ychg = rx;
iforce2d 0:972874f31c98 309 ychg *= rx;
iforce2d 0:972874f31c98 310
iforce2d 0:972874f31c98 311 err = 0;
iforce2d 0:972874f31c98 312
iforce2d 0:972874f31c98 313 stopx = ryry2;
iforce2d 0:972874f31c98 314 stopx *= rx;
iforce2d 0:972874f31c98 315 stopy = 0;
iforce2d 0:972874f31c98 316
iforce2d 0:972874f31c98 317 while( stopx >= stopy )
iforce2d 0:972874f31c98 318 {
iforce2d 0:972874f31c98 319 u8g_draw_filled_ellipse_section(u8g, x, y, x0, y0, option);
iforce2d 0:972874f31c98 320 y++;
iforce2d 0:972874f31c98 321 stopy += rxrx2;
iforce2d 0:972874f31c98 322 err += ychg;
iforce2d 0:972874f31c98 323 ychg += rxrx2;
iforce2d 0:972874f31c98 324 if ( 2*err+xchg > 0 )
iforce2d 0:972874f31c98 325 {
iforce2d 0:972874f31c98 326 x--;
iforce2d 0:972874f31c98 327 stopx -= ryry2;
iforce2d 0:972874f31c98 328 err += xchg;
iforce2d 0:972874f31c98 329 xchg += ryry2;
iforce2d 0:972874f31c98 330 }
iforce2d 0:972874f31c98 331 }
iforce2d 0:972874f31c98 332
iforce2d 0:972874f31c98 333 x = 0;
iforce2d 0:972874f31c98 334 y = ry;
iforce2d 0:972874f31c98 335
iforce2d 0:972874f31c98 336 xchg = ry;
iforce2d 0:972874f31c98 337 xchg *= ry;
iforce2d 0:972874f31c98 338
iforce2d 0:972874f31c98 339 ychg = 1;
iforce2d 0:972874f31c98 340 ychg -= ry;
iforce2d 0:972874f31c98 341 ychg -= ry;
iforce2d 0:972874f31c98 342 ychg *= rx;
iforce2d 0:972874f31c98 343 ychg *= rx;
iforce2d 0:972874f31c98 344
iforce2d 0:972874f31c98 345 err = 0;
iforce2d 0:972874f31c98 346
iforce2d 0:972874f31c98 347 stopx = 0;
iforce2d 0:972874f31c98 348
iforce2d 0:972874f31c98 349 stopy = rxrx2;
iforce2d 0:972874f31c98 350 stopy *= ry;
iforce2d 0:972874f31c98 351
iforce2d 0:972874f31c98 352
iforce2d 0:972874f31c98 353 while( stopx <= stopy )
iforce2d 0:972874f31c98 354 {
iforce2d 0:972874f31c98 355 u8g_draw_filled_ellipse_section(u8g, x, y, x0, y0, option);
iforce2d 0:972874f31c98 356 x++;
iforce2d 0:972874f31c98 357 stopx += ryry2;
iforce2d 0:972874f31c98 358 err += xchg;
iforce2d 0:972874f31c98 359 xchg += ryry2;
iforce2d 0:972874f31c98 360 if ( 2*err+ychg > 0 )
iforce2d 0:972874f31c98 361 {
iforce2d 0:972874f31c98 362 y--;
iforce2d 0:972874f31c98 363 stopy -= rxrx2;
iforce2d 0:972874f31c98 364 err += ychg;
iforce2d 0:972874f31c98 365 ychg += rxrx2;
iforce2d 0:972874f31c98 366 }
iforce2d 0:972874f31c98 367 }
iforce2d 0:972874f31c98 368
iforce2d 0:972874f31c98 369 }
iforce2d 0:972874f31c98 370
iforce2d 0:972874f31c98 371 void u8g_DrawFilledEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option)
iforce2d 0:972874f31c98 372 {
iforce2d 0:972874f31c98 373 /* check for bounding box */
iforce2d 0:972874f31c98 374 {
iforce2d 0:972874f31c98 375 u8g_uint_t rxp, rxp2;
iforce2d 0:972874f31c98 376 u8g_uint_t ryp, ryp2;
iforce2d 0:972874f31c98 377
iforce2d 0:972874f31c98 378 rxp = rx;
iforce2d 0:972874f31c98 379 rxp++;
iforce2d 0:972874f31c98 380 rxp2 = rxp;
iforce2d 0:972874f31c98 381 rxp2 *= 2;
iforce2d 0:972874f31c98 382
iforce2d 0:972874f31c98 383 ryp = ry;
iforce2d 0:972874f31c98 384 ryp++;
iforce2d 0:972874f31c98 385 ryp2 = ryp;
iforce2d 0:972874f31c98 386 ryp2 *= 2;
iforce2d 0:972874f31c98 387
iforce2d 0:972874f31c98 388 if ( u8g_IsBBXIntersection(u8g, x0-rxp, y0-ryp, rxp2, ryp2) == 0)
iforce2d 0:972874f31c98 389 return;
iforce2d 0:972874f31c98 390 }
iforce2d 0:972874f31c98 391
iforce2d 0:972874f31c98 392 u8g_draw_filled_ellipse(u8g, x0, y0, rx, ry, option);
iforce2d 0:972874f31c98 393 }
iforce2d 0:972874f31c98 394