- Timestamp:
- Mar 2, 2008, 5:28:10 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/conic.c
r1462 r2255 28 28 #include "cucul_internals.h" 29 29 30 static void ellipsepoints(cucul_canvas_t *, int, int, int, int, uint32_t );30 static void ellipsepoints(cucul_canvas_t *, int, int, int, int, uint32_t, int); 31 31 32 32 /** \brief Draw a circle on the canvas using the given character. … … 49 49 for(test = 0, dx = 0, dy = r ; dx <= dy ; dx++) 50 50 { 51 ellipsepoints(cv, x, y, dx, dy, ch );52 ellipsepoints(cv, x, y, dy, dx, ch );51 ellipsepoints(cv, x, y, dx, dy, ch, 1); 52 ellipsepoints(cv, x, y, dy, dx, ch, 1); 53 53 54 54 test += test > 0 ? dx - dy-- : dx; … … 138 138 int d1 = b*b - (a*a*b) + (a*a/4); 139 139 140 ellipsepoints(cv, xo, yo, x, y, ch );140 ellipsepoints(cv, xo, yo, x, y, ch, 0); 141 141 142 142 while(a*a*y - a*a/2 > b*b*(x+1)) … … 152 152 } 153 153 x++; 154 ellipsepoints(cv, xo, yo, x, y, ch );154 ellipsepoints(cv, xo, yo, x, y, ch, 0); 155 155 } 156 156 … … 169 169 170 170 y--; 171 ellipsepoints(cv, xo, yo, x, y, ch );171 ellipsepoints(cv, xo, yo, x, y, ch, 0); 172 172 } 173 173 … … 194 194 int d1 = b*b - (a*a*b) + (a*a/4); 195 195 196 ellipsepoints(cv, xo, yo, x, y, '-' );196 ellipsepoints(cv, xo, yo, x, y, '-', 1); 197 197 198 198 while(a*a*y - a*a/2 > b*b*(x+1)) … … 201 201 { 202 202 d1 += b*b*(2*x+1); /* XXX: "Computer Graphics" has + 3 here. */ 203 ellipsepoints(cv, xo, yo, x + 1, y, '0', 1); 203 204 } 204 205 else … … 206 207 d1 += b*b*(2*x*1) + a*a*(-2*y+2); 207 208 y--; 209 ellipsepoints(cv, xo, yo, x + 1, y, '1', 1); 208 210 } 209 211 x++; 210 ellipsepoints(cv, xo, yo, x, y, '-'); 212 213 211 214 } 212 215 … … 218 221 d2 += b*b*(2*x+2) + a*a*(-2*y+3); 219 222 x++; 223 ellipsepoints(cv, xo, yo, x , y - 1, '2', 1); 220 224 } 221 225 else 222 226 { 223 227 d2 += a*a*(-2*y+3); 228 ellipsepoints(cv, xo, yo, x , y - 1, '3', 1); 224 229 } 225 230 226 231 y--; 227 ellipsepoints(cv, xo, yo, x, y, '|'); 232 233 228 234 } 229 235 … … 232 238 233 239 static void ellipsepoints(cucul_canvas_t *cv, int xo, int yo, int x, int y, 234 uint32_t ch )240 uint32_t ch, int thin) 235 241 { 236 242 uint8_t b = 0; … … 245 251 b |= 0x8; 246 252 247 if((b & (0x1|0x4)) == (0x1|0x4)) 248 cucul_put_char(cv, xo + x, yo + y, ch); 249 250 if((b & (0x2|0x4)) == (0x2|0x4)) 251 cucul_put_char(cv, xo - x, yo + y, ch); 252 253 if((b & (0x1|0x8)) == (0x1|0x8)) 254 cucul_put_char(cv, xo + x, yo - y, ch); 255 256 if((b & (0x2|0x8)) == (0x2|0x8)) 257 cucul_put_char(cv, xo - x, yo - y, ch); 258 } 259 253 if((b & (0x1|0x4)) == (0x1|0x4)) { 254 char c = ch; 255 256 if(thin) { 257 switch(c) { 258 case '0': 259 c = '-'; 260 break; 261 case '1': 262 c = ','; 263 break; 264 case '2': 265 c = '/'; 266 break; 267 case '3': 268 c = '|'; 269 break; 270 } 271 272 } 273 cucul_put_char(cv, xo + x, yo + y, c); 274 } 275 if((b & (0x2|0x4)) == (0x2|0x4)) { 276 char c = ch; 277 278 if(thin) { 279 switch(c) { 280 case '0': 281 c = '-'; 282 break; 283 case '1': 284 c = '.'; 285 break; 286 case '2': 287 c = '\\'; 288 break; 289 case '3': 290 c = '|'; 291 break; 292 } 293 294 } 295 cucul_put_char(cv, xo - x, yo + y, c); 296 } 297 298 299 if((b & (0x1|0x8)) == (0x1|0x8)) { 300 char c = ch; 301 302 if(thin) { 303 switch(c) { 304 case '0': 305 c = '-'; 306 break; 307 case '1': 308 c = '`'; 309 break; 310 case '2': 311 c = '\\'; 312 break; 313 case '3': 314 c = '|'; 315 break; 316 } 317 318 } 319 cucul_put_char(cv, xo + x, yo - y, c); 320 } 321 322 if((b & (0x2|0x8)) == (0x2|0x8)) { 323 char c = ch; 324 325 if(thin) { 326 switch(c) { 327 case '0': 328 c = '-'; 329 break; 330 case '1': 331 c = '\''; 332 break; 333 case '2': 334 c = '/'; 335 break; 336 case '3': 337 c = '|'; 338 break; 339 } 340 341 } 342 cucul_put_char(cv, xo - x, yo - y, c); 343 } 344 345 346 } 347
Note: See TracChangeset
for help on using the changeset viewer.