00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "flgrCoreMalloc.h"
00022 #include "flgrCoreDispatch.h"
00023 #include "flgrCoreDataIO.h"
00024 #include "flgrCoreGeometry.h"
00025 #include "flgrCoreVector.h"
00026
00035 #define FLGR_MACRO_GEOMETRY_PARSE_STRING(function,...) \
00036 FLGR_Ret ret; \
00037 FLGR_Vector *vector_color; \
00038 \
00039 \
00040 \
00041 if(dat==NULL) { \
00042 POST_ERROR("Null objects!\n"); \
00043 return FLGR_RET_NULL_OBJECT; \
00044 } \
00045 \
00046 vector_color = flgr_vector_create(dat->spp,dat->type); \
00047 \
00048 if((ret=flgr_vector_import_string(vector_color, color)) \
00049 != FLGR_RET_OK) { \
00050 \
00051 POST_ERROR("String is not valid ""%s""\n",color); \
00052 flgr_vector_destroy(vector_color); \
00053 return ret; \
00054 } \
00055 \
00056 ret = function##_ptr(__VA_ARGS__,vector_color); \
00057 \
00058 flgr_vector_destroy(vector_color); \
00059 \
00060 return ret
00061
00062
00063
00069
00075
00076 #define FLGR_MACRO_DRAW_1D_LINE(dtype) \
00077 int i; \
00078 \
00079 \
00080 \
00081 for(i=x ; i<x+length ; i++) { \
00082 flgr1d_set_data_vector_##dtype(dat,i,color); \
00083 } \
00084 \
00085 return
00086
00087
00088 void flgr1d_draw_line_fgBIT(FLGR_Data1D *dat, int x, int length, FLGR_Vector *color) {
00089 FLGR_MACRO_DRAW_1D_LINE(fgBIT);
00090 }
00091 void flgr1d_draw_line_fgUINT8(FLGR_Data1D *dat, int x, int length, FLGR_Vector *color) {
00092 FLGR_MACRO_DRAW_1D_LINE(fgUINT8);
00093 }
00094 void flgr1d_draw_line_fgUINT16(FLGR_Data1D *dat, int x, int length, FLGR_Vector *color) {
00095 FLGR_MACRO_DRAW_1D_LINE(fgUINT16);
00096 }
00097 void flgr1d_draw_line_fgUINT32(FLGR_Data1D *dat, int x, int length, FLGR_Vector *color) {
00098 FLGR_MACRO_DRAW_1D_LINE(fgUINT32);
00099 }
00100 void flgr1d_draw_line_fgINT8(FLGR_Data1D *dat, int x, int length, FLGR_Vector *color) {
00101 FLGR_MACRO_DRAW_1D_LINE(fgINT8);
00102 }
00103 void flgr1d_draw_line_fgINT16(FLGR_Data1D *dat, int x, int length, FLGR_Vector *color) {
00104 FLGR_MACRO_DRAW_1D_LINE(fgINT16);
00105 }
00106 void flgr1d_draw_line_fgINT32(FLGR_Data1D *dat, int x, int length, FLGR_Vector *color) {
00107 FLGR_MACRO_DRAW_1D_LINE(fgINT32);
00108 }
00109 void flgr1d_draw_line_fgFLOAT32(FLGR_Data1D *dat, int x, int length, FLGR_Vector *color) {
00110 FLGR_MACRO_DRAW_1D_LINE(fgFLOAT32);
00111 }
00112 void flgr1d_draw_line_fgFLOAT64(FLGR_Data1D *dat, int x, int length, FLGR_Vector *color) {
00113 FLGR_MACRO_DRAW_1D_LINE(fgFLOAT64);
00114 }
00115
00116
00118
00125
00126 FLGR_Ret flgr1d_draw_line_ptr(FLGR_Data1D *dat, int x, int length, FLGR_Vector *color) {
00127
00128
00129
00130 if(dat == NULL) {
00131 POST_ERROR("Null objects!\n");
00132 return FLGR_RET_NULL_OBJECT;
00133 }
00134 if(length<0) {
00135 POST_WARNING("length < 0, force it to zero!\n");
00136 length=0;
00137 }
00138
00139 FLGR_DISPATCH_PROCEDURE(dat->type,flgr1d_draw_line,dat,x,length,color);
00140 }
00141
00142
00144
00151
00152 FLGR_Ret flgr1d_draw_line_str(FLGR_Data1D *dat, int x, int length, char *color) {
00153 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr1d_draw_line,dat,x,length);
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00181
00187
00188 #define FLGR_MACRO_DRAW2D_POINT(dtype) \
00189 \
00190 \
00191 if(y<0) return; \
00192 if(x<0) return; \
00193 if(y>=dat->size_y) return; \
00194 if(x>=dat->size_x) return; \
00195 \
00196 flgr2d_set_data_vector_##dtype(dat, y, x, color); \
00197 \
00198 return
00199
00200 void flgr2d_draw_point_fgBIT(FLGR_Data2D *dat, int x, int y, FLGR_Vector *color) {
00201 FLGR_MACRO_DRAW2D_POINT(fgBIT);
00202 }
00203 void flgr2d_draw_point_fgUINT8(FLGR_Data2D *dat, int x, int y, FLGR_Vector *color) {
00204 FLGR_MACRO_DRAW2D_POINT(fgUINT8);
00205 }
00206 void flgr2d_draw_point_fgUINT16(FLGR_Data2D *dat, int x, int y, FLGR_Vector *color) {
00207 FLGR_MACRO_DRAW2D_POINT(fgUINT16);
00208 }
00209 void flgr2d_draw_point_fgUINT32(FLGR_Data2D *dat, int x, int y, FLGR_Vector *color) {
00210 FLGR_MACRO_DRAW2D_POINT(fgUINT32);
00211 }
00212 void flgr2d_draw_point_fgINT8(FLGR_Data2D *dat, int x, int y, FLGR_Vector *color) {
00213 FLGR_MACRO_DRAW2D_POINT(fgINT8);
00214 }
00215 void flgr2d_draw_point_fgINT16(FLGR_Data2D *dat, int x, int y, FLGR_Vector *color) {
00216 FLGR_MACRO_DRAW2D_POINT(fgINT16);
00217 }
00218 void flgr2d_draw_point_fgINT32(FLGR_Data2D *dat, int x, int y, FLGR_Vector *color) {
00219 FLGR_MACRO_DRAW2D_POINT(fgINT32);
00220 }
00221 void flgr2d_draw_point_fgFLOAT32(FLGR_Data2D *dat, int x, int y, FLGR_Vector *color) {
00222 FLGR_MACRO_DRAW2D_POINT(fgFLOAT32);
00223 }
00224 void flgr2d_draw_point_fgFLOAT64(FLGR_Data2D *dat, int x, int y, FLGR_Vector *color) {
00225 FLGR_MACRO_DRAW2D_POINT(fgFLOAT64);
00226 }
00227
00229
00236
00237 FLGR_Ret flgr2d_draw_point_ptr(FLGR_Data2D *dat, int x, int y, FLGR_Vector *color) {
00238
00239
00240 if(dat==NULL) {
00241 POST_ERROR("Null objects!\n");
00242 return FLGR_RET_NULL_OBJECT;
00243 }
00244
00245 FLGR_DISPATCH_PROCEDURE(dat->type,flgr2d_draw_point,dat,x,y,color);
00246 }
00247
00249
00256
00257 FLGR_Ret flgr2d_draw_point_str(FLGR_Data2D *dat, int x, int y, char *color) {
00258 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr2d_draw_point,dat,x,y);
00259 }
00260
00261
00262
00263 #define FLGR_MACRO_DRAW_2D_HORZ_LINE(dtype) \
00264 int i; \
00265 \
00266 \
00267 \
00268 for(i=x;i<x+size_x;i++) { \
00269 flgr2d_draw_point_##dtype(dat,i,y,color); \
00270 } \
00271 return
00272
00273 void flgr2d_draw_horizontal_line_fgBIT(FLGR_Data2D *dat, int x, int y, int size_x, FLGR_Vector *color) {
00274 FLGR_MACRO_DRAW_2D_HORZ_LINE(fgBIT);
00275 }
00276 void flgr2d_draw_horizontal_line_fgUINT8(FLGR_Data2D *dat, int x, int y, int size_x, FLGR_Vector *color) {
00277 FLGR_MACRO_DRAW_2D_HORZ_LINE(fgUINT8);
00278 }
00279 void flgr2d_draw_horizontal_line_fgUINT16(FLGR_Data2D *dat, int x, int y, int size_x, FLGR_Vector *color) {
00280 FLGR_MACRO_DRAW_2D_HORZ_LINE(fgUINT16);
00281 }
00282 void flgr2d_draw_horizontal_line_fgUINT32(FLGR_Data2D *dat, int x, int y, int size_x, FLGR_Vector *color) {
00283 FLGR_MACRO_DRAW_2D_HORZ_LINE(fgUINT32);
00284 }
00285 void flgr2d_draw_horizontal_line_fgINT8(FLGR_Data2D *dat, int x, int y, int size_x, FLGR_Vector *color) {
00286 FLGR_MACRO_DRAW_2D_HORZ_LINE(fgINT8);
00287 }
00288 void flgr2d_draw_horizontal_line_fgINT16(FLGR_Data2D *dat, int x, int y, int size_x, FLGR_Vector *color) {
00289 FLGR_MACRO_DRAW_2D_HORZ_LINE(fgINT16);
00290 }
00291 void flgr2d_draw_horizontal_line_fgINT32(FLGR_Data2D *dat, int x, int y, int size_x, FLGR_Vector *color) {
00292 FLGR_MACRO_DRAW_2D_HORZ_LINE(fgINT32);
00293 }
00294 void flgr2d_draw_horizontal_line_fgFLOAT32(FLGR_Data2D *dat, int x, int y, int size_x, FLGR_Vector *color) {
00295 FLGR_MACRO_DRAW_2D_HORZ_LINE(fgFLOAT32);
00296 }
00297 void flgr2d_draw_horizontal_line_fgFLOAT64(FLGR_Data2D *dat, int x, int y, int size_x, FLGR_Vector *color) {
00298 FLGR_MACRO_DRAW_2D_HORZ_LINE(fgFLOAT64);
00299 }
00300
00302
00310
00311 FLGR_Ret flgr2d_draw_horizontal_line_ptr(FLGR_Data2D *dat, int x, int y, int size_x, FLGR_Vector *color) {
00312
00313
00314 if(dat==NULL) {
00315 POST_ERROR("Null objects!\n");
00316 return FLGR_RET_NULL_OBJECT;
00317 }
00318
00319
00320 if(size_x<0) {
00321 POST_WARNING("size_x < 0, force it to zero!\n");
00322 size_x=0;
00323 }
00324
00325 FLGR_DISPATCH_PROCEDURE(dat->type,flgr2d_draw_horizontal_line,dat,x,y,size_x,color);
00326 }
00327
00329
00337
00338 FLGR_Ret flgr2d_draw_horizontal_line_str(FLGR_Data2D *dat, int x, int y, int size_x, char *color) {
00339 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr2d_draw_horizontal_line,dat,x,y,size_x);
00340 }
00341
00342
00343 #define FLGR_MACRO_DRAW_2D_VERT_LINE(dtype) \
00344 int i; \
00345 \
00346 \
00347 \
00348 for(i=y;i<y+size_y;i++) { \
00349 flgr2d_draw_point_##dtype(dat,x,i,color); \
00350 } \
00351 return
00352
00353 void flgr2d_draw_vertical_line_fgBIT(FLGR_Data2D *dat, int x, int y, int size_y, FLGR_Vector *color) {
00354 FLGR_MACRO_DRAW_2D_VERT_LINE(fgBIT);
00355 }
00356 void flgr2d_draw_vertical_line_fgUINT8(FLGR_Data2D *dat, int x, int y, int size_y, FLGR_Vector *color) {
00357 FLGR_MACRO_DRAW_2D_VERT_LINE(fgUINT8);
00358 }
00359 void flgr2d_draw_vertical_line_fgUINT16(FLGR_Data2D *dat, int x, int y, int size_y, FLGR_Vector *color) {
00360 FLGR_MACRO_DRAW_2D_VERT_LINE(fgUINT16);
00361 }
00362 void flgr2d_draw_vertical_line_fgUINT32(FLGR_Data2D *dat, int x, int y, int size_y, FLGR_Vector *color) {
00363 FLGR_MACRO_DRAW_2D_VERT_LINE(fgUINT32);
00364 }
00365 void flgr2d_draw_vertical_line_fgINT8(FLGR_Data2D *dat, int x, int y, int size_y, FLGR_Vector *color) {
00366 FLGR_MACRO_DRAW_2D_VERT_LINE(fgINT8);
00367 }
00368 void flgr2d_draw_vertical_line_fgINT16(FLGR_Data2D *dat, int x, int y, int size_y, FLGR_Vector *color) {
00369 FLGR_MACRO_DRAW_2D_VERT_LINE(fgINT16);
00370 }
00371 void flgr2d_draw_vertical_line_fgINT32(FLGR_Data2D *dat, int x, int y, int size_y, FLGR_Vector *color) {
00372 FLGR_MACRO_DRAW_2D_VERT_LINE(fgINT32);
00373 }
00374 void flgr2d_draw_vertical_line_fgFLOAT32(FLGR_Data2D *dat, int x, int y, int size_y, FLGR_Vector *color) {
00375 FLGR_MACRO_DRAW_2D_VERT_LINE(fgFLOAT32);
00376 }
00377 void flgr2d_draw_vertical_line_fgFLOAT64(FLGR_Data2D *dat, int x, int y, int size_y, FLGR_Vector *color) {
00378 FLGR_MACRO_DRAW_2D_VERT_LINE(fgFLOAT64);
00379 }
00380
00382
00390
00391 FLGR_Ret flgr2d_draw_vertical_line_ptr(FLGR_Data2D *dat, int x, int y, int size_y, FLGR_Vector *color) {
00392
00393
00394 if(dat==NULL) {
00395 POST_ERROR("Null objects!\n");
00396 return FLGR_RET_NULL_OBJECT;
00397 }
00398
00399 if(size_y<0) {
00400 POST_WARNING("size_y < 0, force it to zero!\n");
00401 size_y = 0;
00402 }
00403
00404 FLGR_DISPATCH_PROCEDURE(dat->type,flgr2d_draw_vertical_line,dat,x,y,size_y,color);
00405 }
00406
00407
00408
00410
00418
00419 FLGR_Ret flgr2d_draw_vertical_line_str(FLGR_Data2D *dat, int x, int y, int size_y, char *color) {
00420 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr2d_draw_vertical_line,dat,x,y,size_y);
00421 }
00422
00423
00424
00425 void dataExchange(int* x, int* y)
00426 {
00427 int t = *x;
00428 *x = *y;
00429 *y = t;
00430 }
00431
00432
00433 #define FLGR_MACRO_DRAW_2D_LINE(dtype) \
00434 int d, dx, dy, aincr, bincr, xincr, yincr, x, y; \
00435 \
00436 \
00437 \
00438 if (abs(x2 - x1) < abs(y2 - y1)) { \
00439 \
00440 \
00441 if (y1 > y2) { \
00442 dataExchange(&x1, &x2); \
00443 dataExchange(&y1, &y2); \
00444 } \
00445 \
00446 xincr = x2 > x1 ? 1 : -1; \
00447 dy = y2 - y1; \
00448 dx = abs(x2 - x1); \
00449 d = 2 * dx - dy; \
00450 aincr = 2 * (dx - dy); \
00451 bincr = 2 * dx; \
00452 x = x1; \
00453 y = y1; \
00454 \
00455 flgr2d_draw_point_##dtype(dat,x,y,color); \
00456 \
00457 for (y = y1+1; y <= y2; ++y) { \
00458 if (d >= 0) { \
00459 x += xincr; \
00460 d += aincr; \
00461 } else \
00462 d += bincr; \
00463 \
00464 flgr2d_draw_point_##dtype(dat,x,y,color); \
00465 } \
00466 \
00467 } else { \
00468 \
00469 \
00470 if (x1 > x2) { \
00471 dataExchange(&x1, &x2); \
00472 dataExchange(&y1, &y2); \
00473 } \
00474 \
00475 yincr = y2 > y1 ? 1 : -1; \
00476 dx = x2 - x1; \
00477 dy = abs(y2 - y1); \
00478 d = 2 * dy - dx; \
00479 aincr = 2 * (dy - dx); \
00480 bincr = 2 * dy; \
00481 x = x1; \
00482 y = y1; \
00483 \
00484 flgr2d_draw_point_##dtype(dat,x,y,color); \
00485 \
00486 for (x = x1+1; x <= x2; ++x) { \
00487 if (d >= 0) { \
00488 y += yincr; \
00489 d += aincr; \
00490 } else \
00491 d += bincr; \
00492 \
00493 flgr2d_draw_point_##dtype(dat,x,y,color); \
00494 } \
00495 } \
00496 return
00497
00498
00499
00500 void flgr2d_draw_line_fgBIT(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, FLGR_Vector *color) {
00501 FLGR_MACRO_DRAW_2D_LINE(fgBIT);
00502 }
00503 void flgr2d_draw_line_fgUINT8(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, FLGR_Vector *color) {
00504 FLGR_MACRO_DRAW_2D_LINE(fgUINT8);
00505 }
00506 void flgr2d_draw_line_fgUINT16(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, FLGR_Vector *color) {
00507 FLGR_MACRO_DRAW_2D_LINE(fgUINT16);
00508 }
00509 void flgr2d_draw_line_fgUINT32(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, FLGR_Vector *color) {
00510 FLGR_MACRO_DRAW_2D_LINE(fgUINT32);
00511 }
00512 void flgr2d_draw_line_fgINT8(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, FLGR_Vector *color) {
00513 FLGR_MACRO_DRAW_2D_LINE(fgINT8);
00514 }
00515 void flgr2d_draw_line_fgINT16(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, FLGR_Vector *color) {
00516 FLGR_MACRO_DRAW_2D_LINE(fgINT16);
00517 }
00518 void flgr2d_draw_line_fgINT32(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, FLGR_Vector *color) {
00519 FLGR_MACRO_DRAW_2D_LINE(fgINT32);
00520 }
00521 void flgr2d_draw_line_fgFLOAT32(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, FLGR_Vector *color) {
00522 FLGR_MACRO_DRAW_2D_LINE(fgFLOAT32);
00523 }
00524 void flgr2d_draw_line_fgFLOAT64(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, FLGR_Vector *color) {
00525 FLGR_MACRO_DRAW_2D_LINE(fgFLOAT64);
00526 }
00527
00528
00530
00539
00540 FLGR_Ret flgr2d_draw_line_ptr(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, FLGR_Vector *color) {
00541
00542
00543 if(dat==NULL) {
00544 POST_ERROR("Null objects!\n");
00545 return FLGR_RET_NULL_OBJECT;
00546 }
00547
00548 FLGR_DISPATCH_PROCEDURE(dat->type,flgr2d_draw_line,dat,x1,y1,x2,y2,color);
00549
00550 }
00551
00553
00562
00563 FLGR_Ret flgr2d_draw_line_str(FLGR_Data2D *dat, int x1, int y1, int x2, int y2, char *color) {
00564 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr2d_draw_line,dat,x1,y1,x2,y2);
00565 }
00566
00567
00568
00569 #define FLGR_MACRO_DRAW_2D_RECT(dtype) \
00570 \
00571 \
00572 flgr2d_draw_horizontal_line_##dtype(dat,x, y, size_x , color); \
00573 flgr2d_draw_horizontal_line_##dtype(dat,x, y + size_y - 1, size_x, \
00574 color); \
00575 flgr2d_draw_vertical_line_##dtype(dat,x, y + 1, size_y - 2, color); \
00576 flgr2d_draw_vertical_line_##dtype(dat,x + size_x - 1, y + 1, \
00577 size_y - 2, color); \
00578 return
00579
00580 void flgr2d_draw_rectangle_fgBIT(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00581 FLGR_MACRO_DRAW_2D_RECT(fgBIT);
00582 }
00583 void flgr2d_draw_rectangle_fgUINT8(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00584 FLGR_MACRO_DRAW_2D_RECT(fgUINT8);
00585 }
00586 void flgr2d_draw_rectangle_fgUINT16(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00587 FLGR_MACRO_DRAW_2D_RECT(fgUINT16);
00588 }
00589 void flgr2d_draw_rectangle_fgUINT32(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00590 FLGR_MACRO_DRAW_2D_RECT(fgUINT32);
00591 }
00592 void flgr2d_draw_rectangle_fgINT8(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00593 FLGR_MACRO_DRAW_2D_RECT(fgINT8);
00594 }
00595 void flgr2d_draw_rectangle_fgINT16(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00596 FLGR_MACRO_DRAW_2D_RECT(fgINT16);
00597 }
00598 void flgr2d_draw_rectangle_fgINT32(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00599 FLGR_MACRO_DRAW_2D_RECT(fgINT32);
00600 }
00601 void flgr2d_draw_rectangle_fgFLOAT32(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00602 FLGR_MACRO_DRAW_2D_RECT(fgFLOAT32);
00603 }
00604 void flgr2d_draw_rectangle_fgFLOAT64(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00605 FLGR_MACRO_DRAW_2D_RECT(fgFLOAT64);
00606 }
00607
00609
00618
00619 FLGR_Ret flgr2d_draw_rectangle_ptr(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00620
00621
00622 if(dat==NULL) {
00623 POST_ERROR("Null objects!\n");
00624 return FLGR_RET_NULL_OBJECT;
00625 }
00626
00627
00628 if(size_y<0) {
00629 POST_WARNING("size_y < 0, force it to zero!\n");
00630 size_y = 0;
00631 }
00632
00633 if(size_x<0) {
00634 POST_WARNING("size_x < 0, force it to zero!\n");
00635 size_x = 0;
00636 }
00637
00638 FLGR_DISPATCH_PROCEDURE(dat->type,flgr2d_draw_rectangle,dat,x,y,size_x,size_y,color);
00639
00640 }
00641
00642
00644
00653
00654 FLGR_Ret flgr2d_draw_rectangle_str(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, char *color) {
00655 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr2d_draw_rectangle,dat,x,y,size_x,size_y);
00656 }
00657
00658
00659
00660 #define FLGR_MACRO_DRAW_2D_FILLED_RECT(dtype) \
00661 int i; \
00662 \
00663 \
00664 \
00665 for(i=y; i<y+size_y ; i++) \
00666 flgr2d_draw_horizontal_line_##dtype(dat,x, i, size_x , color); \
00667 return
00668
00669 void flgr2d_draw_filled_rectangle_fgBIT(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00670 FLGR_MACRO_DRAW_2D_FILLED_RECT(fgBIT);
00671 }
00672 void flgr2d_draw_filled_rectangle_fgUINT8(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00673 FLGR_MACRO_DRAW_2D_FILLED_RECT(fgUINT8);
00674 }
00675 void flgr2d_draw_filled_rectangle_fgUINT16(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00676 FLGR_MACRO_DRAW_2D_FILLED_RECT(fgUINT16);
00677 }
00678 void flgr2d_draw_filled_rectangle_fgUINT32(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00679 FLGR_MACRO_DRAW_2D_FILLED_RECT(fgUINT32);
00680 }
00681 void flgr2d_draw_filled_rectangle_fgINT8(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00682 FLGR_MACRO_DRAW_2D_FILLED_RECT(fgINT8);
00683 }
00684 void flgr2d_draw_filled_rectangle_fgINT16(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00685 FLGR_MACRO_DRAW_2D_FILLED_RECT(fgINT16);
00686 }
00687 void flgr2d_draw_filled_rectangle_fgINT32(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00688 FLGR_MACRO_DRAW_2D_FILLED_RECT(fgINT32);
00689 }
00690 void flgr2d_draw_filled_rectangle_fgFLOAT32(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00691 FLGR_MACRO_DRAW_2D_FILLED_RECT(fgFLOAT32);
00692 }
00693 void flgr2d_draw_filled_rectangle_fgFLOAT64(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00694 FLGR_MACRO_DRAW_2D_FILLED_RECT(fgFLOAT64);
00695 }
00696
00697
00699
00708
00709 FLGR_Ret flgr2d_draw_filled_rectangle_ptr(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, FLGR_Vector *color) {
00710
00711
00712 if(dat==NULL) {
00713 POST_ERROR("Null objects!\n");
00714 return FLGR_RET_NULL_OBJECT;
00715 }
00716
00717 if(size_y<0) {
00718 POST_WARNING("size_y < 0, force it to zero!\n");
00719 size_y = 0;
00720 }
00721
00722 if(size_x<0) {
00723 POST_WARNING("size_x < 0, force it to zero!\n");
00724 size_x = 0;
00725 }
00726
00727 FLGR_DISPATCH_PROCEDURE(dat->type,flgr2d_draw_filled_rectangle,dat,x,y,size_x,size_y,color);
00728
00729 }
00730
00732
00741
00742 FLGR_Ret flgr2d_draw_filled_rectangle_str(FLGR_Data2D *dat, int x, int y, int size_x, int size_y, char *color) {
00743 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr2d_draw_filled_rectangle,dat,x,y,size_x,size_y);
00744 }
00745
00746
00747
00748 #define FLGR_MACRO_DRAW_2D_2D_CIRCLE(dtype) \
00749 int d, y, x; \
00750 \
00751 \
00752 \
00753 d = 3 - (2 * radius); \
00754 x = 0; \
00755 y = radius; \
00756 \
00757 while (y >= x) { \
00758 if( (cy+y>=0) && (cy+y<dat->size_y) ) { \
00759 if( (cx+x>=0) && (cx+x<dat->size_x) ) \
00760 flgr2d_draw_point_##dtype(dat,cx+x,cy+y,color); \
00761 if( (cx-x>=0) && (cx-x<dat->size_x) ) \
00762 flgr2d_draw_point_##dtype(dat,cx-x,cy+y,color); \
00763 } \
00764 \
00765 if( (cy+x>=0) && (cy+x<dat->size_y) ) { \
00766 if( (cx+y>=0) && (cx+y<dat->size_x) ) \
00767 flgr2d_draw_point_##dtype(dat,cx+y,cy+x,color); \
00768 if( (cx-y>=0) && (cx-y<dat->size_x) ) \
00769 flgr2d_draw_point_##dtype(dat,cx-y,cy+x,color); \
00770 } \
00771 \
00772 if((cy-y>=0) && (cy-y<dat->size_y) ) { \
00773 if( (cx+x>=0) && (cx+x<dat->size_x) ) \
00774 flgr2d_draw_point_##dtype(dat,cx+x,cy-y,color); \
00775 if( (cx-x>=0) && (cx-x<dat->size_x) ) \
00776 flgr2d_draw_point_##dtype(dat,cx-x,cy-y,color); \
00777 } \
00778 \
00779 if((cy-x>=0) && (cy-x<dat->size_y) ) { \
00780 if( (cx+y>=0) && (cx+y<dat->size_x) ) \
00781 flgr2d_draw_point_##dtype(dat,cx+y,cy-x,color); \
00782 if( (cx-y>=0) && (cx-y<dat->size_x) ) \
00783 flgr2d_draw_point_##dtype(dat,cx-y,cy-x,color); \
00784 } \
00785 \
00786 if (d < 0) \
00787 d = d + (4 * x) + 6; \
00788 else { \
00789 d = d + 4 * (x - y) + 10; \
00790 y--; \
00791 } \
00792 \
00793 x++; \
00794 } \
00795 return
00796
00797 void flgr2d_draw_circle_fgBIT(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00798 FLGR_MACRO_DRAW_2D_2D_CIRCLE(fgBIT);
00799 }
00800 void flgr2d_draw_circle_fgUINT8(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00801 FLGR_MACRO_DRAW_2D_2D_CIRCLE(fgUINT8);
00802 }
00803 void flgr2d_draw_circle_fgUINT16(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00804 FLGR_MACRO_DRAW_2D_2D_CIRCLE(fgUINT16);
00805 }
00806 void flgr2d_draw_circle_fgUINT32(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00807 FLGR_MACRO_DRAW_2D_2D_CIRCLE(fgUINT32);
00808 }
00809 void flgr2d_draw_circle_fgINT8(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00810 FLGR_MACRO_DRAW_2D_2D_CIRCLE(fgINT8);
00811 }
00812 void flgr2d_draw_circle_fgINT16(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00813 FLGR_MACRO_DRAW_2D_2D_CIRCLE(fgINT16);
00814 }
00815 void flgr2d_draw_circle_fgINT32(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00816 FLGR_MACRO_DRAW_2D_2D_CIRCLE(fgINT32);
00817 }
00818 void flgr2d_draw_circle_fgFLOAT32(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00819 FLGR_MACRO_DRAW_2D_2D_CIRCLE(fgFLOAT32);
00820 }
00821 void flgr2d_draw_circle_fgFLOAT64(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00822 FLGR_MACRO_DRAW_2D_2D_CIRCLE(fgFLOAT64);
00823 }
00824
00825
00827
00835
00836 FLGR_Ret flgr2d_draw_circle_ptr(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00837
00838
00839 if(dat==NULL) {
00840 POST_ERROR("Null objects!\n");
00841 return FLGR_RET_NULL_OBJECT;
00842 }
00843
00844 FLGR_DISPATCH_PROCEDURE(dat->type,flgr2d_draw_circle,dat,cx,cy,radius,color);
00845
00846 }
00847
00849
00857
00858 FLGR_Ret flgr2d_draw_circle_str(FLGR_Data2D *dat, int cx, int cy, int radius, char *color) {
00859 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr2d_draw_circle,dat,cx,cy,radius);
00860 }
00861
00862
00863
00864
00865 #define FLGR_MACRO_DRAW_2D_2D_DISC(dtype) \
00866 int d, y, x; \
00867 \
00868 \
00869 \
00870 d = 3 - (2 * radius); \
00871 x = 0; \
00872 y = radius; \
00873 \
00874 while (y >= x) { \
00875 flgr2d_draw_horizontal_line_##dtype(dat, cx-x, cy-y, 2*x+1, color); \
00876 flgr2d_draw_horizontal_line_##dtype(dat, cx-x, cy+y, 2*x+1, color); \
00877 flgr2d_draw_horizontal_line_##dtype(dat, cx-y, cy-x, 2*y+1, color); \
00878 flgr2d_draw_horizontal_line_##dtype(dat, cx-y, cy+x, 2*y+1, color); \
00879 \
00880 if (d < 0) \
00881 d = d + (4 * x) + 6; \
00882 else { \
00883 d = d + 4 * (x - y) + 10; \
00884 y--; \
00885 } \
00886 \
00887 x++; \
00888 } \
00889 return
00890
00891
00892 void flgr2d_draw_disc_fgBIT(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00893 FLGR_MACRO_DRAW_2D_2D_DISC(fgBIT);
00894 }
00895 void flgr2d_draw_disc_fgUINT8(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00896 FLGR_MACRO_DRAW_2D_2D_DISC(fgUINT8);
00897 }
00898 void flgr2d_draw_disc_fgUINT16(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00899 FLGR_MACRO_DRAW_2D_2D_DISC(fgUINT16);
00900 }
00901 void flgr2d_draw_disc_fgUINT32(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00902 FLGR_MACRO_DRAW_2D_2D_DISC(fgUINT32);
00903 }
00904 void flgr2d_draw_disc_fgINT8(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00905 FLGR_MACRO_DRAW_2D_2D_DISC(fgINT8);
00906 }
00907 void flgr2d_draw_disc_fgINT16(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00908 FLGR_MACRO_DRAW_2D_2D_DISC(fgINT16);
00909 }
00910 void flgr2d_draw_disc_fgINT32(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00911 FLGR_MACRO_DRAW_2D_2D_DISC(fgINT32);
00912 }
00913 void flgr2d_draw_disc_fgFLOAT32(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00914 FLGR_MACRO_DRAW_2D_2D_DISC(fgFLOAT32);
00915 }
00916 void flgr2d_draw_disc_fgFLOAT64(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00917 FLGR_MACRO_DRAW_2D_2D_DISC(fgFLOAT64);
00918 }
00919
00921
00929
00930 FLGR_Ret flgr2d_draw_disc_ptr(FLGR_Data2D *dat, int cx, int cy, int radius, FLGR_Vector *color) {
00931
00932
00933 if(dat==NULL) {
00934 POST_ERROR("Null objects!\n");
00935 return FLGR_RET_NULL_OBJECT;
00936 }
00937
00938 FLGR_DISPATCH_PROCEDURE(dat->type,flgr2d_draw_disc,dat,cx,cy,radius,color);
00939 }
00940
00941
00943
00951
00952 FLGR_Ret flgr2d_draw_disc_str(FLGR_Data2D *dat, int cx, int cy, int radius, char *color) {
00953 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr2d_draw_disc,dat,cx,cy,radius);
00954 }
00955
00956
00957
00958 #define FLGR_MACRO_DRAW_2D_2D_ELLIPSE(dtype) \
00959 \
00960 int x = 0, y = b; \
00961 long a2 = (long)a*a, b2 = (long)b*b; \
00962 long crit1 = -(a2/4 + a%2 + b2); \
00963 long crit2 = -(b2/4 + b%2 + a2); \
00964 long crit3 = -(b2/4 + b%2); \
00965 long t = -a2*y; \
00966 long dxt = 2*b2*x, dyt = -2*a2*y; \
00967 long d2xt = 2*b2, d2yt = 2*a2; \
00968 \
00969 \
00970 \
00971 while (y>=0 && x<=a) { \
00972 flgr2d_draw_point_##dtype(dat, cx+x, cy+y, color); \
00973 if (x!=0 || y!=0) \
00974 flgr2d_draw_point_##dtype(dat, cx-x, cy-y, color); \
00975 if (x!=0 && y!=0) { \
00976 flgr2d_draw_point_##dtype(dat, cx+x, cy-y, color); \
00977 flgr2d_draw_point_##dtype(dat, cx-x, cy+y, color); \
00978 } \
00979 if (t + b2*x <= crit1 || \
00980 t + a2*y <= crit3) \
00981 x++, dxt += d2xt, t += dxt; \
00982 else if (t - a2*y > crit2) \
00983 y--, dyt += d2yt, t += dyt; \
00984 else { \
00985 x++, dxt += d2xt, t += dxt; \
00986 y--, dyt += d2yt, t += dyt; \
00987 } \
00988 } \
00989 return
00990
00991
00992 void flgr2d_draw_ellipse_fgBIT(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
00993 FLGR_MACRO_DRAW_2D_2D_ELLIPSE(fgBIT);
00994 }
00995 void flgr2d_draw_ellipse_fgUINT8(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
00996 FLGR_MACRO_DRAW_2D_2D_ELLIPSE(fgUINT8);
00997 }
00998 void flgr2d_draw_ellipse_fgUINT16(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
00999 FLGR_MACRO_DRAW_2D_2D_ELLIPSE(fgUINT16);
01000 }
01001 void flgr2d_draw_ellipse_fgUINT32(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01002 FLGR_MACRO_DRAW_2D_2D_ELLIPSE(fgUINT32);
01003 }
01004 void flgr2d_draw_ellipse_fgINT8(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01005 FLGR_MACRO_DRAW_2D_2D_ELLIPSE(fgINT8);
01006 }
01007 void flgr2d_draw_ellipse_fgINT16(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01008 FLGR_MACRO_DRAW_2D_2D_ELLIPSE(fgINT16);
01009 }
01010 void flgr2d_draw_ellipse_fgINT32(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01011 FLGR_MACRO_DRAW_2D_2D_ELLIPSE(fgINT32);
01012 }
01013 void flgr2d_draw_ellipse_fgFLOAT32(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01014 FLGR_MACRO_DRAW_2D_2D_ELLIPSE(fgFLOAT32);
01015 }
01016 void flgr2d_draw_ellipse_fgFLOAT64(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01017 FLGR_MACRO_DRAW_2D_2D_ELLIPSE(fgFLOAT64);
01018 }
01020
01029
01030 FLGR_Ret flgr2d_draw_ellipse_ptr(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01031
01032
01033 if(dat==NULL) {
01034 POST_ERROR("Null objects!\n");
01035 return FLGR_RET_NULL_OBJECT;
01036 }
01037
01038 FLGR_DISPATCH_PROCEDURE(dat->type,flgr2d_draw_ellipse,dat,cx,cy,a,b,color);
01039 }
01040
01041
01043
01055
01056 FLGR_Ret flgr2d_draw_ellipse_str(FLGR_Data2D *dat, int cx, int cy, int a, int b, char *color) {
01057 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr2d_draw_ellipse,dat,cx,cy,a,b);
01058 }
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069 #define FLGR_MACRO_DRAW_2D_2D_FILLED_ELLIPSE(dtype) \
01070 \
01071 int x = 0, y = b; \
01072 unsigned int width = 1; \
01073 long a2 = (long)a*a, b2 = (long)b*b; \
01074 long crit1 = -(a2/4 + a%2 + b2); \
01075 long crit2 = -(b2/4 + b%2 + a2); \
01076 long crit3 = -(b2/4 + b%2); \
01077 long t = -a2*y; \
01078 long dxt = 2*b2*x, dyt = -2*a2*y; \
01079 long d2xt = 2*b2, d2yt = 2*a2; \
01080 \
01081 \
01082 \
01083 while (y>=0 && x<=a) { \
01084 if (t + b2*x <= crit1 || \
01085 t + a2*y <= crit3) { \
01086 x++, dxt += d2xt, t += dxt; \
01087 width += 2; \
01088 } \
01089 else if (t - a2*y > crit2) { \
01090 flgr2d_draw_horizontal_line_##dtype(dat,cx-x,cy-y,width,color); \
01091 if (y!=0) \
01092 flgr2d_draw_horizontal_line_##dtype(dat,cx-x,cy+y,width,color); \
01093 y--, dyt += d2yt, t += dyt; \
01094 } \
01095 else { \
01096 flgr2d_draw_horizontal_line_##dtype(dat,cx-x,cy-y,width,color); \
01097 if (y!=0) \
01098 flgr2d_draw_horizontal_line_##dtype(dat,cx-x,cy+y,width,color); \
01099 x++, dxt += d2xt, t += dxt; \
01100 y--, dyt += d2yt, t += dyt; \
01101 width += 2; \
01102 } \
01103 } \
01104 if (b == 0) \
01105 flgr2d_draw_horizontal_line_##dtype(dat,cx-a, cy, 2*a+1,color); \
01106 \
01107 return
01108
01109
01110 void flgr2d_draw_filled_ellipse_fgBIT(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01111 FLGR_MACRO_DRAW_2D_2D_FILLED_ELLIPSE(fgBIT);
01112 }
01113 void flgr2d_draw_filled_ellipse_fgUINT8(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01114 FLGR_MACRO_DRAW_2D_2D_FILLED_ELLIPSE(fgUINT8);
01115 }
01116 void flgr2d_draw_filled_ellipse_fgUINT16(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01117 FLGR_MACRO_DRAW_2D_2D_FILLED_ELLIPSE(fgUINT16);
01118 }
01119 void flgr2d_draw_filled_ellipse_fgUINT32(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01120 FLGR_MACRO_DRAW_2D_2D_FILLED_ELLIPSE(fgUINT32);
01121 }
01122 void flgr2d_draw_filled_ellipse_fgINT8(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01123 FLGR_MACRO_DRAW_2D_2D_FILLED_ELLIPSE(fgINT8);
01124 }
01125 void flgr2d_draw_filled_ellipse_fgINT16(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01126 FLGR_MACRO_DRAW_2D_2D_FILLED_ELLIPSE(fgINT16);
01127 }
01128 void flgr2d_draw_filled_ellipse_fgINT32(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01129 FLGR_MACRO_DRAW_2D_2D_FILLED_ELLIPSE(fgINT32);
01130 }
01131 void flgr2d_draw_filled_ellipse_fgFLOAT32(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01132 FLGR_MACRO_DRAW_2D_2D_FILLED_ELLIPSE(fgFLOAT32);
01133 }
01134 void flgr2d_draw_filled_ellipse_fgFLOAT64(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01135 FLGR_MACRO_DRAW_2D_2D_FILLED_ELLIPSE(fgFLOAT64);
01136 }
01138
01150
01151 FLGR_Ret flgr2d_draw_filled_ellipse_ptr(FLGR_Data2D *dat, int cx, int cy, int a, int b, FLGR_Vector *color) {
01152
01153
01154 if(dat==NULL) {
01155 POST_ERROR("Null objects!\n");
01156 return FLGR_RET_NULL_OBJECT;
01157 }
01158
01159 FLGR_DISPATCH_PROCEDURE(dat->type,flgr2d_draw_filled_ellipse,dat,cx,cy,a,b,color);
01160 }
01161
01162
01164
01173
01174 FLGR_Ret flgr2d_draw_filled_ellipse_str(FLGR_Data2D *dat, int cx, int cy, int a, int b, char *color) {
01175 FLGR_MACRO_GEOMETRY_PARSE_STRING(flgr2d_draw_filled_ellipse,dat,cx,cy,a,b);
01176 }
01177
01178
01179
01180