E:/PPC/XFlib/source/xf_vecto.c

Go to the documentation of this file.
00001 
00002 #include "xf_buffer.h"
00003 #include "xf_vecto.h"
00004 #include "xf_bg.h"
00005 #include <malloc.h>
00006 
00007 void xf_DoVect(u8 bg);
00008 
00009 
00010 
00011 void XF_LoadVectoBg(u8 number){
00012 
00013         xf_dovecto = xf_DoVect;
00014 
00015         // si le bg existe déjà
00016         if (xf_bg[number].Alive){
00017                 // on vérifie qu'il n'y a pas d'objets vectoriels déjà créés
00018                 if (xf_bg[number].vectObjects){
00019                         // sinon on les efface ...
00020                         xf_vectObject * ptr;
00021 
00022                         while (xf_bg[number].vectObjects){
00023                                 ptr = xf_bg[number].vectObjects;
00024                                 while (ptr->next) ptr = ptr->next;
00025                                 free(ptr);
00026                         }
00027                 }
00028 
00029         }
00030         else{
00031                 // si le fond n'existe pas, on en crée un, vide
00032                 xf_bg[number].Alive = 1;
00033                 xf_bg[number].Alpha = 32;
00034                 xf_bg[number].Priority = number; // Priorit? classique
00035                 xf_bg[number].BgMode = BG_BLANK;
00036                 xf_bg[number].vectObjects = NULL;
00037         }
00038 
00039 }
00040 
00041 xf_vectObject* XF_VectoNew(u8 bg){
00042         xf_vectObject * ptr = xf_bg[bg].vectObjects;
00043         
00044         if (ptr){
00045                 while (ptr->next) ptr=ptr->next;
00046                 ptr->next = malloc(sizeof(xf_vectObject));
00047                 ptr = ptr->next;
00048         }
00049         else {
00050                 xf_bg[bg].vectObjects = malloc(sizeof(xf_vectObject));
00051                 ptr = xf_bg[bg].vectObjects;
00052         }   
00053         ptr->next = 0; // Rien après  
00054         
00055         return ptr;
00056 }  
00057 
00058 
00059 void XF_ResetVecto(u8 bg){
00060         xf_vectObject *ptr;
00061         xf_vectObject *next;
00062         ptr = next = xf_bg[bg].vectObjects;
00063         
00064         xf_bg[bg].vectObjects = 0;
00065         
00066         while(ptr){
00067         
00068                 next = ptr->next;
00069                 free(ptr);
00070                 
00071                 ptr = next;
00072         }
00073 }
00074 
00075 void XF_VectoDelete(xf_vectObject* ptr){
00076         // Circulez !
00077         
00078         
00079 
00080 }
00081 
00082 
00083 
00084 void XF_VectoChgLine(xf_vectObject* ptr, s32 x1, s32 y1, s32 x2, s32 y2, u16 color, u8 alpha){
00085 
00086         ptr->objectType = VECT_LINE;
00087         ptr->x1 = x1; ptr->y1 = y1;
00088         ptr->x2 = x2; ptr->y2 = y2;
00089         ptr->color = color; ptr->alpha = alpha;
00090 } 
00091 
00092 xf_vectObject* XF_VectoAddLine(u8 bg, s32 x1, s32 y1, s32 x2, s32 y2, u16 color, u8 alpha)
00093 {
00094         xf_vectObject* ptr = XF_VectoNew(bg);
00095         XF_VectoChgLine(ptr, x1, y1, x2, y2, color, alpha);
00096         return ptr;
00097 }
00098 
00099 void XF_VectoChgRectangle(xf_vectObject* ptr, s32 x1, s32 y1, s32 x2, s32 y2, u8 bordersize, u16 bordercolor, u16 color, s8 alpha)
00100 {
00101         ptr->objectType = VECT_RECTANGLE;
00102         ptr->x1 = x1; ptr->y1 = y1;
00103         ptr->x2 = x2; ptr->y2 = y2;
00104         ptr->color = color; ptr->alpha = alpha;
00105         ptr->bordercolor = bordercolor;
00106         ptr->bordersize = bordersize;    
00107 }   
00108 
00109 
00110 xf_vectObject* XF_VectoAddRectangle(u8 bg, s32 x1, s32 y1, s32 x2, s32 y2, u8 bordersize, u16 bordercolor, u16 color, s8 alpha)
00111 {
00112         xf_vectObject* ptr = XF_VectoNew(bg);
00113         XF_VectoChgRectangle(ptr, x1, y1, x2, y2, bordersize, bordercolor, color, alpha);
00114         return ptr;
00115 }
00116 
00117 void XF_VectoChgGradient(xf_vectObject* ptr, s32 x1, s32 y1, s32 x2, s32 y2, u16 color0, u16 color1, s8 alpha)
00118 {
00119         ptr->objectType = VECT_GRADIENT;
00120         ptr->x1 = x1; ptr->y1 = y1;
00121         ptr->x2 = x2; ptr->y2 = y2;
00122         ptr->color = color1; ptr->alpha = alpha;
00123         ptr->bordercolor = color0; 
00124 }   
00125 
00126 
00127 xf_vectObject* XF_VectoAddGradient(u8 bg, s32 x1, s32 y1, s32 x2, s32 y2, u16 color0, u16 color1, s8 alpha)
00128 {
00129         xf_vectObject* ptr = XF_VectoNew(bg);
00130         XF_VectoChgGradient(ptr, x1, y1, x2, y2, color0, color1, alpha);
00131         
00132         return ptr;
00133 }
00134 
00135 
00136 
00137 
00138 void xf_vectlineAlpha(s32 x1, s32 y1, s32 x2, s32 y2, u16 color, s8 alpha){
00139 
00140         s32 dx, dy, i, x1nc, y1nc, cumul, x, y;
00141         s32 temp;
00142         x = x1;
00143         y = y1;
00144         dx = x2 - x1;
00145         dy = y2 - y1;
00146         
00147         
00148         x1nc = (dx > 0) ? 1 : -1;
00149         y1nc = (dy > 0) ? 1 : -1;
00150         
00151         if (dx < 0) {
00152            dx=-dx;
00153            temp = x1;
00154            x1 = x2;
00155            x2 = temp;
00156         }       
00157 
00158         if (dy < 0) {
00159            dy=-dy;
00160            temp = y1;
00161            y1 = y2;
00162            y2 = temp;
00163         }       
00164         
00165         XF_AdjustCopyLimits(x1, y1, dx, dy);
00166         x2 = x1 + xf_limits.maxx-1;     y2 = y1 + xf_limits.maxy-1;
00167         x1 += xf_limits.minx;           y1 += xf_limits.miny;
00168         
00169         if((x >= x1) && (x < x2) && (y >= y1) && (y < y2))      XF_SetPixelAlpha(x, y, color, alpha);
00170         
00171         
00172 
00173         if (dx > dy){
00174 
00175                 cumul = dx>>1;
00176                 
00177                 
00178                 for (i=1; (i<=dx)&& !((x >= x1) && (x < x2) && (y >= y1) && (y < y2)); i++){
00179 
00180                         x += x1nc;
00181                         cumul += dy;
00182                         if (cumul >= dx){
00183                                 cumul -= dx;
00184                                 y += y1nc;
00185                         }
00186                 }
00187                 
00188                 if((x >= x1) && (x < x2) && (y >= y1) && (y < y2)){
00189                         for (; (i<=dx) && (x >= x1) && (x < x2) && (y >= y1) && (y < y2); i++){
00190         
00191                                 x += x1nc;
00192                                 cumul += dy;
00193                                 if (cumul >= dx){
00194                                         cumul -= dx;
00195                                         y += y1nc;
00196                                 }
00197                                 XF_SetPixelAlpha(x, y, color, alpha);
00198                         }
00199                 }               
00200         }
00201         else{
00202 
00203                 cumul = dy>>1;
00204                 for (i=1; (i<=dy) && !((x >= x1) && (x < x2) && (y >= y1) && (y < y2)); i++){
00205 
00206                         y += y1nc;
00207                         cumul += dx;
00208                         if (cumul >= dy){
00209                                 cumul -= dy;
00210                                 x += x1nc;
00211                         }
00212                 }               
00213                 
00214                 
00215                 if((x >= x1) && (x < x2) && (y >= y1) && (y < y2)){
00216                 
00217                         for (; (i<=dy)&&(x >= x1) && (x < x2) && (y >= y1) && (y < y2); i++){
00218         
00219                                 y += y1nc;
00220                                 cumul += dx;
00221                                 if (cumul >= dy){
00222                                         cumul -= dy;
00223                                         x += x1nc;
00224                                 }
00225                                 XF_SetPixelAlpha(x, y, color, alpha);
00226                         }
00227                 }               
00228         }
00229 
00230 }
00231 
00232 
00233 
00234 void xf_vectline(s32 x1, s32 y1, s32 x2, s32 y2, u16 color){
00235 
00236         s32 dx, dy, i, x1nc, y1nc, cumul, x, y;
00237         s32 temp;
00238         x = x1;
00239         y = y1;
00240         dx = x2 - x1;
00241         dy = y2 - y1;
00242         
00243         
00244         x1nc = (dx > 0) ? 1 : -1;
00245         y1nc = (dy > 0) ? 1 : -1;
00246         
00247         if (dx < 0) {
00248            dx=-dx;
00249            temp = x1;
00250            x1 = x2;
00251            x2 = temp;
00252         }       
00253 
00254         if (dy < 0) {
00255            dy=-dy;
00256            temp = y1;
00257            y1 = y2;
00258            y2 = temp;
00259         }       
00260         
00261         XF_AdjustCopyLimits(x1, y1, dx, dy);
00262         x2 = x1 + xf_limits.maxx-1;     y2 = y1 + xf_limits.maxy-1;
00263         x1 += xf_limits.minx;           y1 += xf_limits.miny;
00264         
00265 
00266         if((x >= x1) && (x < x2) && (y >= y1) && (y < y2))      XF_SetPixel(x, y, color);
00267         
00268         
00269 
00270         if (dx > dy){
00271 
00272                 cumul = dx>>1;
00273                 
00274                 
00275                 for (i=1; (i<=dx)&& !((x >= x1) && (x < x2) && (y >= y1) && (y < y2)); i++){
00276 
00277                         x += x1nc;
00278                         cumul += dy;
00279                         if (cumul >= dx){
00280                                 cumul -= dx;
00281                                 y += y1nc;
00282                         }
00283                 }
00284                 
00285                 if((x >= x1) && (x < x2) && (y >= y1) && (y < y2)){
00286                         for (; (i<=dx) && (x >= x1) && (x < x2) && (y >= y1) && (y < y2); i++){
00287         
00288                                 x += x1nc;
00289                                 cumul += dy;
00290                                 if (cumul >= dx){
00291                                         cumul -= dx;
00292                                         y += y1nc;
00293                                 }
00294                                 XF_SetPixel(x, y, color);
00295                         }
00296                 }               
00297         }
00298         else{
00299 
00300                 cumul = dy>>1;
00301                 for (i=1; (i<=dy) && !((x >= x1) && (x < x2) && (y >= y1) && (y < y2)); i++){
00302 
00303                         y += y1nc;
00304                         cumul += dx;
00305                         if (cumul >= dy){
00306                                 cumul -= dy;
00307                                 x += x1nc;
00308                         }
00309                 }               
00310                 
00311                 
00312                 if((x >= x1) && (x < x2) && (y >= y1) && (y < y2)){
00313                 
00314                         for (; (i<=dy)&&(x >= x1) && (x < x2) && (y >= y1) && (y < y2); i++){
00315         
00316                                 y += y1nc;
00317                                 cumul += dx;
00318                                 if (cumul >= dy){
00319                                         cumul -= dy;
00320                                         x += x1nc;
00321                                 }
00322                                 XF_SetPixel(x, y, color);
00323                         }
00324                 }               
00325         }
00326 
00327 }
00328 
00329 void DrawWuLine (s32 X0, s16 Y0, s16 X1, s16 Y1,
00330          u16 BaseColor)
00331 {
00332    unsigned short IntensityBits = 5;
00333    unsigned short IntensityShift, ErrorAdj, ErrorAcc;
00334    unsigned short ErrorAccTemp, Weighting, WeightingComplementMask;
00335    short DeltaX, DeltaY, Temp, XDir;
00336    short NumLevels = 32;
00337 
00338    /* Make sure the line runs top to bottom */
00339    if (Y0 > Y1) {
00340       Temp = Y0; Y0 = Y1; Y1 = Temp;
00341       Temp = X0; X0 = X1; X1 = Temp;
00342    }
00343       
00344    XF_SetPixel(X0, Y0, BaseColor);
00345 
00346    if ((DeltaX = X1 - X0) >= 0) {
00347       XDir = 1;
00348    } else {
00349       XDir = -1;
00350       DeltaX = -DeltaX; /* make DeltaX positive */
00351    }
00352 
00353    if ((DeltaY = Y1 - Y0) == 0) {
00354       while (DeltaX-- != 0) {
00355          X0 += XDir;
00356          XF_SetPixel(X0, Y0, BaseColor);
00357       }
00358       return;
00359    }
00360    if (DeltaX == 0) {
00361       do {
00362          Y0++;
00363          XF_SetPixel(X0, Y0, BaseColor);
00364       } while (--DeltaY != 0);
00365       return;
00366    }
00367    if (DeltaX == DeltaY) {
00368       do {
00369          X0 += XDir;
00370          Y0++;
00371          XF_SetPixel(X0, Y0, BaseColor);
00372       } while (--DeltaY != 0);
00373       return;
00374    }
00375    /* Line is not horizontal, diagonal, or vertical */
00376    ErrorAcc = 0; 
00377    IntensityShift = 16 - IntensityBits;
00378    WeightingComplementMask = NumLevels - 1;
00379 
00380    if (DeltaY > DeltaX) {
00381       ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY;
00382       /* Draw all pixels other than the first and last */
00383       while (--DeltaY) {
00384          ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */
00385          ErrorAcc += ErrorAdj;      /* calculate error for next pixel */
00386          if (ErrorAcc <= ErrorAccTemp) {
00387             X0 += XDir;
00388          }
00389          Y0++; 
00390          Weighting = ErrorAcc >> IntensityShift;
00391          XF_SetPixelAlpha(X0, Y0, BaseColor, 32-Weighting);
00392          XF_SetPixelAlpha(X0 + XDir, Y0, BaseColor, 32-(Weighting ^ WeightingComplementMask));
00393       }
00394 
00395       XF_SetPixel(X1, Y1, BaseColor);
00396       return;
00397    }
00398 
00399    ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX;
00400    /* Draw all pixels other than the first and last */
00401    while (--DeltaX) {
00402       ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */
00403       ErrorAcc += ErrorAdj;      /* calculate error for next pixel */
00404       if (ErrorAcc <= ErrorAccTemp) {
00405          /* The error accumulator turned over, so advance the Y coord */
00406          Y0++;
00407       }
00408       X0 += XDir; 
00409           
00410       Weighting = ErrorAcc >> IntensityShift;
00411       XF_SetPixelAlpha(X0, Y0, BaseColor, 32-Weighting);
00412       XF_SetPixelAlpha(X0, Y0+1, BaseColor, 32-(Weighting ^ WeightingComplementMask));
00413    }
00414 
00415    XF_SetPixel(X1, Y1, BaseColor);
00416 }
00417 
00418 
00419 void DrawWuLineAlpha (s32 X0, s16 Y0, s16 X1, s16 Y1,
00420          u16 BaseColor, s32 alpha)
00421 {
00422    unsigned short IntensityBits = 5;
00423    unsigned short IntensityShift, ErrorAdj, ErrorAcc;
00424    unsigned short ErrorAccTemp, Weighting, WeightingComplementMask;
00425    short DeltaX, DeltaY, Temp, XDir;
00426    short NumLevels = 32;
00427 
00428    /* Make sure the line runs top to bottom */
00429    if (Y0 > Y1) {
00430       Temp = Y0; Y0 = Y1; Y1 = Temp;
00431       Temp = X0; X0 = X1; X1 = Temp;
00432    }
00433       
00434    XF_SetPixelAlpha(X0, Y0, BaseColor, alpha);
00435 
00436    if ((DeltaX = X1 - X0) >= 0) {
00437       XDir = 1;
00438    } else {
00439       XDir = -1;
00440       DeltaX = -DeltaX; /* make DeltaX positive */
00441    }
00442 
00443    if ((DeltaY = Y1 - Y0) == 0) {
00444       while (DeltaX-- != 0) {
00445          X0 += XDir;
00446          XF_SetPixelAlpha(X0, Y0, BaseColor, alpha);
00447       }
00448       return;
00449    }
00450    if (DeltaX == 0) {
00451       do {
00452          Y0++;
00453          XF_SetPixelAlpha(X0, Y0, BaseColor, alpha);
00454       } while (--DeltaY != 0);
00455       return;
00456    }
00457    if (DeltaX == DeltaY) {
00458       do {
00459          X0 += XDir;
00460          Y0++;
00461          XF_SetPixelAlpha(X0, Y0, BaseColor, alpha);
00462       } while (--DeltaY != 0);
00463       return;
00464    }
00465    /* Line is not horizontal, diagonal, or vertical */
00466    ErrorAcc = 0; 
00467    IntensityShift = 16 - IntensityBits;
00468    WeightingComplementMask = NumLevels - 1;
00469 
00470    if (DeltaY > DeltaX) {
00471       ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY;
00472       /* Draw all pixels other than the first and last */
00473       while (--DeltaY) {
00474          ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */
00475          ErrorAcc += ErrorAdj;      /* calculate error for next pixel */
00476          if (ErrorAcc <= ErrorAccTemp) {
00477             X0 += XDir;
00478          }
00479          Y0++; 
00480          Weighting = ErrorAcc >> IntensityShift;
00481          XF_SetPixelAlpha(X0, Y0, BaseColor, ((32-Weighting)*alpha)>>5);
00482          XF_SetPixelAlpha(X0 + XDir, Y0, BaseColor, ((32-(Weighting ^ WeightingComplementMask))*alpha)>>5);
00483       }
00484 
00485       XF_SetPixelAlpha(X1, Y1, BaseColor, alpha);
00486       return;
00487    }
00488 
00489    ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX;
00490    /* Draw all pixels other than the first and last */
00491    while (--DeltaX) {
00492       ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */
00493       ErrorAcc += ErrorAdj;      /* calculate error for next pixel */
00494       if (ErrorAcc <= ErrorAccTemp) {
00495          /* The error accumulator turned over, so advance the Y coord */
00496          Y0++;
00497       }
00498       X0 += XDir; 
00499           
00500       Weighting = ErrorAcc >> IntensityShift;
00501       XF_SetPixelAlpha(X0, Y0, BaseColor, (((32-Weighting)*alpha)>>5));
00502       XF_SetPixelAlpha(X0, Y0+1, BaseColor, (((32-(Weighting ^ WeightingComplementMask))*alpha)>>5));
00503    }
00504 
00505    XF_SetPixelAlpha(X1, Y1, BaseColor, alpha);
00506 }
00507 
00508 
00509 
00510 
00511 
00512 
00513 extern inline void xf_plotline(s16 startx, s16 endx, s16 y, u16 color){
00514    u32 bigcolor = color | (color << 16);
00515         s16 x;
00516    
00517    if((startx&1) && (startx < endx)){ // Impair...
00518       XF_SetPixel(startx, y, bigcolor);
00519       startx++;
00520    }   
00521    
00522    u32 *buffer;
00523    buffer = (u32*)(xf_buffer+startx+y*WIDTH);
00524         for(x = startx; x < endx-1; x+=2) {
00525            *(buffer++) = bigcolor;
00526    }
00527                 
00528         endx--;
00529    if(((endx&1) == 0)&&(endx > startx)){ // Impair...
00530       XF_SetPixel(endx, y, bigcolor);
00531    }   
00532 
00533    
00534 }   
00535 
00536 extern inline u16 xf_vectalpha(u32 color0, u32 color1, s32 alpha){
00537    if(alpha == 32) return color0;
00538    if(alpha == 0) return color1;
00539         color0 = (color0 | (color0<<16)) & ALPHA_MASK;
00540         color1 = (color1 | (color1<<16)) & ALPHA_MASK;
00541 
00542         //do alpha op
00543         color0 = ((((color0-color1)*alpha)>>5) + color1)&ALPHA_MASK;
00544 
00545         //recombine colors
00546         return (color0 | (color0 >> 16));
00547 }   
00548 
00549 
00550 void xf_vectgradient(s32 x1, s32 y1, s32 x2, s32 y2, u16 color0, u16 color1, u8 alpha){
00551    s16 temp, tempcol;
00552 
00553    // Bon ordre
00554    if(x1 > x2) {
00555       temp = x1;
00556       x1 = x2;
00557       x2 = temp;
00558         }   
00559    if(y1 > y2) {
00560       temp = y1;
00561       y1 = y2;
00562       y2 = temp;
00563       tempcol = color0;
00564       color0 = color1;
00565       color1 = tempcol; // Invert colors
00566         }   
00567               
00568    XF_AdjustCopyLimits(x1, y1, x2+1-x1, y2+1-y1); 
00569           
00570    s16 y;
00571         
00572         u32 div = (1 << 16) / (y2 - y1 + 1);
00573 
00574         if((xf_limits.minx > xf_limits.maxx) || (xf_limits.miny > xf_limits.maxy)) return;
00575         
00576         if(alpha == 32){                
00577            for(y = xf_limits.miny; y < xf_limits.maxy; y++) {
00578               tempcol = xf_vectalpha(color0, color1, 32-((div*y)>>11));
00579                    xf_plotline(x1 + xf_limits.minx, x1 + xf_limits.maxx, y1, tempcol);
00580                    y1++;
00581                 }               
00582            
00583         }               
00584         else{
00585 /*         for(y = starty; y < endy; y++) {
00586                 for(x = startx; x < endx; x++) {
00587                  XF_SetPixelAlpha(x, y, color, alpha);
00588               }
00589                 }               */         
00590         }   
00591    
00592    
00593 }
00594 
00595 
00596 
00597 
00598 void xf_vectrectangle(s32 x1, s32 y1, s32 x2, s32 y2, u8 bordersize, u16 bordercolor, u16 color, u8 alpha){
00599    s16 temp;
00600    
00601    // Bon ordre
00602    if(x1 > x2) {
00603       temp = x1;
00604       x1 = x2;
00605       x2 = temp;
00606         }   
00607    if(y1 > y2) {
00608       temp = y1;
00609       y1 = y2;
00610       y2 = temp;
00611         }   
00612         
00613 //      XF_DebugText(0, 2, "%d %d %d %d   ", x1, y1, x2, y2);
00614       
00615    XF_AdjustCopyLimits(x1, y1, x2+1-x1, y2+1-y1); 
00616 
00617 //      XF_DebugText(0, 3, "%d %d %d %d   ", xf_limits.minx, xf_limits.miny, xf_limits.maxx, xf_limits.maxy);
00618           
00619    s16 x, y;
00620   
00621         if((bordercolor != xf_transpcolor) && (bordersize)){ 
00622            // Haut et gauche...
00623            if(alpha == 32){
00624                    for(y = xf_limits.miny; (y < bordersize) && (y < xf_limits.maxy); y++){  
00625                       xf_plotline(x1+xf_limits.minx, x1+xf_limits.maxx, y+y1, bordercolor);
00626                         }       
00627                         
00628                    for(x = xf_limits.minx; (x < bordersize) && (x < xf_limits.maxx); x++){  
00629                            for(y = xf_limits.miny+1; y < xf_limits.maxy-1; y++){
00630                               XF_SetPixel(x + x1, y + y1, bordercolor);
00631                            }   
00632                         }       
00633                         
00634                    for(y = xf_limits.maxy-1; (y > (y2-y1) - bordersize) && (y >= xf_limits.miny); y--){  
00635                            xf_plotline(x1+xf_limits.minx, x1+xf_limits.maxx, y+y1, bordercolor);
00636                         }       
00637                         
00638                    for(x = xf_limits.maxx-1; (x > (x2-x1) - bordersize) && (x >= xf_limits.minx); x--){  
00639                            for(y = xf_limits.miny+1; y < xf_limits.maxy-1; y++){
00640                               XF_SetPixel(x + x1, y + y1, bordercolor);
00641                            }   
00642                         }               
00643                 }               
00644                 else{
00645                    for(y = xf_limits.miny; (y < bordersize) && (y < xf_limits.maxy); y++){  
00646                            for(x = xf_limits.minx; x < xf_limits.maxx; x++){
00647                               XF_SetPixelAlpha(x + x1, y + y1, bordercolor, alpha);
00648                            }   
00649                         }       
00650                         
00651                    for(x = xf_limits.minx; (x < bordersize) && (x < xf_limits.maxx); x++){  
00652                            for(y = xf_limits.miny+1; y < xf_limits.maxy-1; y++){
00653                               XF_SetPixelAlpha(x + x1, y + y1, bordercolor, alpha);
00654                            }   
00655                         }       
00656                         
00657                    for(y = xf_limits.maxy-1; (y > (y2-y1) - bordersize) && (y >= xf_limits.miny); y--){  
00658                            for(x = xf_limits.minx; x < xf_limits.maxx; x++){
00659                               XF_SetPixelAlpha(x + x1, y + y1, bordercolor, alpha);
00660                            }   
00661                         }       
00662                         
00663                    for(x = xf_limits.maxx-1; (x > (x2-x1) - bordersize) && (x >= xf_limits.minx); x--){  
00664                            for(y = xf_limits.miny+1; y < xf_limits.maxy-1; y++){
00665                               XF_SetPixelAlpha(x + x1, y + y1, bordercolor, alpha);
00666                            }   
00667                         }                  
00668                 }                                       
00669                 
00670         }       
00671 
00672           
00673         if(color != xf_transpcolor){        // Si visible...
00674                 s16 startx, starty, endx, endy;
00675                 startx = x1+bordersize; if(startx < x1+xf_limits.minx) startx = x1+xf_limits.minx;
00676                 starty = y1 + bordersize; if(starty < y1 + xf_limits.miny) starty = y1 + xf_limits.miny;                
00677                 endx = x2+1-bordersize; if(endx > x1+xf_limits.maxx) endx = x1+xf_limits.maxx;
00678                 endy = y2+1-bordersize; if(endy > y1+xf_limits.maxy) endy = y1+xf_limits.maxy;
00679 
00680                 if((startx >= endx) || (starty >= endy)) return;
00681                 
00682                 if(alpha == 32){
00683                    for(y = starty; y < endy; y++) xf_plotline(startx, endx, y, color);
00684                 }               
00685                 else{
00686                    for(y = starty; y < endy; y++) {
00687                         for(x = startx; x < endx; x++) {
00688                          XF_SetPixelAlpha(x, y, color, alpha);
00689                       }
00690                         }                          
00691                 }   
00692         }       
00693    
00694    
00695 }
00696 
00697 
00698 
00699 void XF_VectoChgCircle(xf_vectObject* ptr, s32 x, s32 y, s16 bordersize, u16 bordercolor, u16 color, s8 alpha)
00700 {
00701         ptr->objectType = VECT_CIRCLE;
00702         ptr->x1 = x; ptr->y1 = y;
00703         ptr->color = color; ptr->alpha = alpha;
00704         ptr->bordercolor = bordercolor;
00705         ptr->bordersize = bordersize;   
00706 }   
00707 
00708 
00709 xf_vectObject* XF_VectoAddCircle(u8 bg, s32 x, s32 y, s16 bordersize, u16 bordercolor, u16 color, s8 alpha)
00710 {
00711         xf_vectObject* ptr = XF_VectoNew(bg);
00712         XF_VectoChgCircle(ptr, x, y, bordersize, bordercolor, color, alpha);
00713         return ptr;
00714 }
00715 
00716 
00717 
00718 void xf_vectcircle(s16 xCenter, s16 yCenter, s16 Radius, u16 bordercolor, u16 color, u16 alpha){
00719    
00720     int x=0;
00721     int y=Radius;
00722     int p=(5-(Radius<<2))>>2; //Midpoint Algorithm
00723     
00724     XF_SetPixel(xCenter  , yCenter+y, bordercolor);
00725     XF_SetPixel(xCenter  , yCenter-y, bordercolor);
00726     XF_SetPixel(xCenter+y, yCenter  , bordercolor);
00727     XF_SetPixel(xCenter-y, yCenter  , bordercolor);
00728     
00729          while(x++<y) {
00730       if(p<0) p+=1+(x<<1);
00731       else    p+=1+((x- --y)<<1);
00732       if(x<y) {
00733         XF_SetPixel(xCenter+x, yCenter+y, bordercolor);
00734         XF_SetPixel(xCenter-x, yCenter+y, bordercolor);
00735         XF_SetPixel(xCenter+x, yCenter-y, bordercolor);
00736         XF_SetPixel(xCenter-x, yCenter-y, bordercolor);
00737         XF_SetPixel(xCenter+y, yCenter+x, bordercolor);
00738         XF_SetPixel(xCenter-y, yCenter+x, bordercolor);
00739         XF_SetPixel(xCenter+y, yCenter-x, bordercolor);
00740         XF_SetPixel(xCenter-y, yCenter-x, bordercolor);
00741       }
00742                 else if(x==y) 
00743                 {
00744         XF_SetPixel(xCenter+x, yCenter+y, bordercolor);
00745         XF_SetPixel(xCenter-x, yCenter+y, bordercolor);
00746         XF_SetPixel(xCenter+x, yCenter-y, bordercolor);
00747         XF_SetPixel(xCenter-x, yCenter-y, bordercolor);
00748                 }
00749         }
00750 }   
00751 
00752 
00753 
00754 
00755 
00756 void xf_DoVect(u8 bg){
00757         u16 alpha;
00758         
00759         xf_vectObject *o = xf_bg[bg].vectObjects;
00760 
00761         while (o){
00762            alpha = (o->alpha * xf_bg[bg].Alpha)>>5; // Alpha combiné
00763                 
00764                 if (o->objectType == VECT_LINE){
00765                    if(alpha == 32) DrawWuLine(o->x1, o->y1, o->x2, o->y2, o->color);// xf_vectline(o->x1, o->y1, o->x2, o->y2, o->color);
00766                    else DrawWuLineAlpha(o->x1, o->y1, o->x2, o->y2, o->color, alpha);// xf_vectline(o->x1, o->y1, o->x2, o->y2, o->color);//xf_vectlineAlpha(o->x1, o->y1, o->x2, o->y2, o->color, alpha);
00767                 }
00768                 else if (o->objectType == VECT_RECTANGLE){
00769                         xf_vectrectangle(o->x1, o->y1, o->x2, o->y2, o->bordersize, o->bordercolor, o->color, alpha);
00770                 }
00771                 else if (o->objectType == VECT_GRADIENT){
00772                         xf_vectgradient(o->x1, o->y1, o->x2, o->y2, o->bordercolor, o->color, alpha);
00773                 }
00774                 else if (o->objectType == VECT_CIRCLE){
00775                         xf_vectcircle(o->x1, o->y1, o->bordersize, o->bordercolor, o->color, alpha);
00776                 }
00777 
00778                 o = o->next;
00779         }
00780 
00781 }
00782 

Generated on Wed Dec 12 23:46:38 2007 for XFlib by  doxygen 1.5.4