Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.         functions for draw controls
  3. */
  4.  
  5. //---------------------------------------------------------------------------------
  6. //                              fill buffer by value
  7. //---------------------------------------------------------------------------------
  8. void FillArrea(void *buf,DWORD size,BYTE bits_per_pixel,DWORD value)
  9. {
  10.         DWORD   i,j;
  11.         char    r,g,b;
  12.  
  13.         switch(bits_per_pixel)
  14.         {
  15.                 case 32:
  16.                 {
  17.                         j=(size >> 2);
  18.                         for(i=0;i<j;i++)
  19.                         {
  20.                                 *(DWORD*)buf=(DWORD)value;
  21.                                 buf=(DWORD*)buf+1;
  22.                         }
  23.                         break;
  24.                 }
  25.                 case 24:
  26.                 {
  27.                         b=value & 0xff;
  28.                         value=value >> 8;
  29.                         g=value & 0xff;
  30.                         value=value >> 8;
  31.                         r=value & 0xff;
  32.  
  33.                         j=(size/3);
  34.                         for(i=0;i<j;i++)
  35.                         {
  36.                                 *(char*)buf=(char)b;
  37.                                 *((char*)buf+1)=(char)g;
  38.                                 *((char*)buf+2)=(char)r;
  39.                                 buf=(char*)buf+3;
  40.                         }
  41.                         break;
  42.                 }
  43.                 case 16:
  44.                 {
  45.                         break;
  46.                 }
  47.                 case 8:
  48.                 {
  49.                         break;
  50.                 }
  51.                 case 4:
  52.                 {
  53.                         break;
  54.                 }
  55.                 default: break;
  56.         }
  57. }
  58.  
  59. //---------------------------------------------------------------------------------
  60. //                              draw pixel on screen
  61. //---------------------------------------------------------------------------------
  62. void DrawPixel(int x,int y,DWORD color)
  63. {
  64.         char            r,g,b;
  65.         char            *ptr;
  66.         DWORD   *ptr2;
  67.  
  68.         if (x>screen.size_x-1) {x=screen.size_x-1;}
  69.         if (y>screen.size_y-1) {y=screen.size_y-1;}
  70.         if (x<0) {x=0;}
  71.         if (y<0) {y=0;}
  72.  
  73.         switch(screen.draw_output)
  74.         {
  75.                 case DRAW_OUTPUT_SCREEN:
  76.                 {
  77.                         x+=screen.x;
  78.                         y+=screen.y;
  79.                         gui_ksys_put_pixel_window(x,y,color);
  80.                         break;
  81.                 }
  82.                 case DRAW_OUTPUT_BUFFER:
  83.                 {
  84.                         ptr=screen.buffer;
  85.                         switch(screen.bits_per_pixel)
  86.                         {
  87.                                 case 24:
  88.                                 {
  89.                                         ptr=ptr+(y*screen.size_x+x)*3;
  90.                                         b=color & 0xff;
  91.                                         color=color >>8;
  92.                                         g=color & 0xff;
  93.                                         color=color >>8;
  94.                                         r=color & 0xff;
  95.  
  96.                                         ptr[0]=b;
  97.                                         ptr[1]=g;
  98.                                         ptr[2]=r;
  99.                                         break;
  100.                                 }
  101.                                 case 32:
  102.                                 {
  103.                                         ptr2=(DWORD*)ptr+y*screen.size_x+x;
  104.                                         *ptr2=color;
  105.                                         break;
  106.                                 }
  107.                                 default: break;
  108.                         }
  109.                         break;
  110.                 }
  111.         }
  112. }
  113.  
  114. //---------------------------------------------------------------------------------
  115. //              libGUI function drawing pixels on screen with finition
  116. //---------------------------------------------------------------------------------
  117. void DrawPixelFinit(struct FINITION *fin,int x,int y,DWORD color)
  118. {
  119.         if (x>=fin->x && x<=fin->x+fin->sizex-1 &&
  120.                 y>=fin->y && y<=fin->y+fin->sizey-1) DrawPixel(x,y,color);
  121. }
  122.  
  123.  
  124. //---------------------------------------------------------------------------------
  125. //                      get color of pixel inc coordinates x,y
  126. //---------------------------------------------------------------------------------
  127. DWORD GetColorPixel(int x,int y)
  128. {
  129.         char            r,g,b;
  130.         char            *ptr;
  131.         DWORD   color,coordinates;
  132.         DWORD   *ptr2;
  133.  
  134.         if (x>screen.size_x-1) {x=screen.size_x-1;}
  135.         if (y>screen.size_y-1) {y=screen.size_y-1;}
  136.         if (x<0) {x=0;}
  137.         if (y<0) {y=0;}
  138.  
  139.         switch(screen.draw_output)
  140.         {
  141.                 case DRAW_OUTPUT_SCREEN:
  142.                 {
  143.                         x+=screen.x;
  144.                         y+=screen.y;
  145.                         coordinates=x;
  146.                         coordinates=coordinates << 16;
  147.                         coordinates +=y;
  148.                         color=gui_ksys_get_color_pixel_window(coordinates);
  149.                         break;
  150.                 }
  151.                 case DRAW_OUTPUT_BUFFER:
  152.                 {
  153.                         ptr=screen.buffer;
  154.                         switch(screen.bits_per_pixel)
  155.                         {
  156.                                 case 24:
  157.                                 {
  158.                                         ptr=ptr+(y*screen.size_x+x)*3;
  159.                                         color=*ptr;
  160.                                         color=color & 0xffffff;
  161.                                         break;
  162.                                 }
  163.                                 case 32:
  164.                                 {
  165.                                         ptr2=(DWORD*)ptr+y*screen.size_x+x;
  166.                                         color=*ptr2;
  167.                                         break;
  168.                                 }
  169.                                 default: break;
  170.                         }
  171.                 }
  172.         }
  173.         return(color);
  174. }
  175.  
  176. //---------------------------------------------------------------------------------
  177. //                              draw vertical line on screen
  178. //---------------------------------------------------------------------------------
  179. void DrawVerticalLine(int x,int y1,int y2,DWORD color)
  180. {
  181.         char            r,g,b;
  182.         char            *ptr;
  183.         DWORD   *ptr2;
  184.         int             a,i,count;
  185.  
  186.         if (x>screen.size_x-1) {x=screen.size_x-1;}
  187.         if (y1>screen.size_y-1) {y1=screen.size_y-1;}
  188.         if (y2>screen.size_y-1) {y2=screen.size_y-1;}
  189.         if (x<0) {x=0;}
  190.         if (y1<0) {y1=0;}
  191.         if (y2<0) {y2=0;}
  192.  
  193.         switch(screen.draw_output)
  194.         {
  195.                 case DRAW_OUTPUT_SCREEN:
  196.                 {
  197.                         x+=screen.x;
  198.                         y1+=screen.y;
  199.                         y2+=screen.y;
  200.                         gui_ksys_draw_line_window(x,y1,x,y2,color);
  201.                         break;
  202.                 }
  203.                 case DRAW_OUTPUT_BUFFER:
  204.                 {
  205.                         if (y1<y2)      {a=y1;count=y2-y1;}
  206.                                 else
  207.                                         {a=y2;count=y1-y2;}
  208.  
  209.                         ptr=screen.buffer;
  210.                         switch(screen.bits_per_pixel)
  211.                         {
  212.                                 case 24:
  213.                                 {
  214.                                         ptr=ptr+(a*screen.size_x+x)*3;
  215.                                         b=color & 0xff;
  216.                                         color=color >>8;
  217.                                         g=color & 0xff;
  218.                                         color=color >>8;
  219.                                         r=color & 0xff;
  220.  
  221.                                         a=screen.size_x*3;
  222.                                         for(i=0;i<=count;i++)
  223.                                         {
  224.                                                 ptr[0]=b;
  225.                                                 ptr[1]=g;
  226.                                                 ptr[2]=r;
  227.                                                 ptr+=a;
  228.                                         }
  229.                                         break;
  230.                                 }
  231.                                 case 32:
  232.                                 {
  233.                                         ptr2=(DWORD*)ptr+a*screen.size_x+x;
  234.                                         a=screen.size_x;
  235.                                         for(i=0;i<=count;i++)
  236.                                         {
  237.                                                 *ptr2=color;
  238.                                                 ptr2+=a;
  239.                                         }
  240.                                         break;
  241.                                 }
  242.                                 default: break;
  243.                         }
  244.                 }
  245.         }
  246. }
  247.  
  248. //---------------------------------------------------------------------------------
  249. //                      draw finited vertical line on screen
  250. //---------------------------------------------------------------------------------
  251. void DrawVerticalLineFinit(struct FINITION *fin,int x,int y1,int y2,DWORD color)
  252. {
  253.         int     xmin,xmax,ymin,ymax,v,sy;
  254.  
  255.         xmin=fin->x;
  256.         xmax=fin->x+fin->sizex-1;
  257.         ymin=fin->y;
  258.         ymax=fin->y+fin->sizey-1;
  259.  
  260.         if (y2<y1)
  261.         {
  262.                 v=y1;
  263.                 y1=y2;
  264.                 y2=v;
  265.         }
  266.  
  267.         if (x<xmin) return;
  268.         if (x>xmax) return;
  269.         if (y2<ymin) return;
  270.         if (y1>ymax) return;
  271.  
  272.         //finit x coordinates and sizex
  273.         sy=y1-ymin;
  274.  
  275.         if (sy>=0)
  276.         {
  277.                 if (y2>ymax) y2=ymax;
  278.         }
  279.         else
  280.         {
  281.                 y1=ymin;
  282.                 if (y2>ymax)    y2=ymax;
  283.         }
  284.         DrawVerticalLine(x,y1,y2,color);
  285. }
  286.  
  287. //---------------------------------------------------------------------------------
  288. //                      draw horizontal line on screen
  289. //---------------------------------------------------------------------------------
  290. void DrawHorizontalLine(int x1,int x2,int y,DWORD color)
  291. {
  292.         char            r,g,b;
  293.         char            *ptr;
  294.         int             a,i,count;
  295.         DWORD   *ptr2;
  296.  
  297.         if (y>screen.size_y-1) {y=screen.size_y-1;}
  298.         if (x1>screen.size_x-1) {x1=screen.size_x-1;}
  299.         if (x2>screen.size_x-1) {x2=screen.size_x-1;}
  300.         if (y<0) {y=0;}
  301.         if (x1<0) {x1=0;}
  302.         if (x2<0) {x2=0;}
  303.  
  304.         switch(screen.draw_output)
  305.         {
  306.                 case DRAW_OUTPUT_SCREEN:
  307.                 {
  308.                         x1+=screen.x;
  309.                         x2+=screen.x;
  310.                         y+=screen.y;
  311.                         gui_ksys_draw_line_window(x1,y,x2,y,color);
  312.                         break;
  313.                 }
  314.                 case DRAW_OUTPUT_BUFFER:
  315.                 {
  316.                         if (x1<x2)      {a=x1;count=x2-x1;}
  317.                                 else
  318.                                         {a=x2;count=x1-x2;}
  319.  
  320.                         ptr=screen.buffer;
  321.                         switch(screen.bits_per_pixel)
  322.                         {
  323.                                 case 24:
  324.                                 {
  325.                                         ptr=ptr+(y*screen.size_x+a)*3;
  326.                                         b=color & 0xff;
  327.                                         color=color >>8;
  328.                                         g=color & 0xff;
  329.                                         color=color >>8;
  330.                                         r=color & 0xff;
  331.  
  332.                                         for(i=0;i<=count;i++)
  333.                                         {
  334.                                                 ptr[0]=b;
  335.                                                 ptr[1]=g;
  336.                                                 ptr[2]=r;
  337.                                                 ptr=ptr+3;
  338.                                         }
  339.                                         break;
  340.                                 }
  341.                                 case 32:
  342.                                 {
  343.                                         ptr2=(DWORD*)ptr+y*screen.size_x+a;
  344.  
  345.                                         for(i=0;i<=count;i++)
  346.                                         {
  347.                                                 *ptr2=color;ptr2++;
  348.                                         }
  349.                                         break;
  350.                                 }
  351.                                 default:break;
  352.                         }
  353.                 }
  354.         }
  355. }
  356.  
  357. //---------------------------------------------------------------------------------
  358. //                      draw finited vertical line on screen
  359. //---------------------------------------------------------------------------------
  360. void DrawHorizontalLineFinit(struct FINITION *fin,int x1,int x2,int y,DWORD color)
  361. {
  362.         int     xmin,xmax,ymin,ymax,v,sx;
  363.  
  364.         xmin=fin->x;
  365.         xmax=fin->x+fin->sizex-1;
  366.         ymin=fin->y;
  367.         ymax=fin->y+fin->sizey-1;
  368.  
  369.         if (x2<x1)
  370.         {
  371.                 v=x1;
  372.                 x1=x2;
  373.                 x2=v;
  374.         }
  375.  
  376.         if (y<ymin) return;
  377.         if (y>ymax) return;
  378.         if (x2<xmin) return;
  379.         if (x1>xmax) return;
  380.  
  381.         //finit x coordinates and sizex
  382.         sx=x1-xmin;
  383.  
  384.         if (sx>=0)
  385.         {
  386.                 if (x2>xmax) x2=xmax;
  387.         }
  388.         else
  389.         {
  390.                 x1=xmin;
  391.                 if (x2>xmax)    x2=xmax;
  392.         }
  393.         DrawHorizontalLine(x1,x2,y,color);
  394. }
  395.  
  396. //---------------------------------------------------------------------------------
  397. //                      libGUI function drawing line on screen
  398. //---------------------------------------------------------------------------------
  399. int sign(int value)
  400. {
  401.         if (value==0) return(0);
  402.         if (value<0) {return(-1);}
  403.         else {return(1);}
  404. }
  405.  
  406. int abs(int value)
  407. {
  408.         if (value<0) {value=-value;}
  409.  
  410.         return(value);
  411. }
  412.  
  413. void DrawLine(int x1, int y1, int x2, int y2,DWORD color)
  414. {
  415.     int x;
  416.     int y;
  417.     int dx;
  418.     int dy;
  419.     int sx;
  420.     int sy;
  421.     int z;
  422.     int e;
  423.     int i;
  424.     char ch;
  425.  
  426.         switch(screen.draw_output)
  427.         {
  428.                 case DRAW_OUTPUT_SCREEN:
  429.                 {
  430.                         if (y1>screen.size_y-1) {y1=screen.size_y-1;}
  431.                         if (y2>screen.size_y-1) {y2=screen.size_y-1;}
  432.                         if (x1>screen.size_x-1) {x1=screen.size_x-1;}
  433.                         if (x2>screen.size_x-1) {x2=screen.size_x-1;}
  434.                         if (y1<0) {y1=0;}
  435.                         if (y2<0) {y2=0;}
  436.                         if (x1<0) {x1=0;}
  437.                         if (x2<0) {x2=0;}
  438.  
  439.                         x1+=screen.x;
  440.                         x2+=screen.x;
  441.                         y1+=screen.y;
  442.                         y2+=screen.y;
  443.                         gui_ksys_draw_line_window(x1,y1,x2,y2,color);
  444.                         break;
  445.                 }
  446.                 case DRAW_OUTPUT_BUFFER:
  447.                 {
  448.  
  449.                         x = x1;
  450.                         y = y1;
  451.                         dx = abs(x2-x1);
  452.                         dy = abs(y2-y1);
  453.                         sx = sign(x2-x1);
  454.                         sy = sign(y2-y1);
  455.  
  456.                         if( dx==0 && dy==0 )
  457.                         {
  458.                                 DrawPixel(x1, y1,color);
  459.                                 return;
  460.                         }
  461.                         if( dy>dx )
  462.                         {
  463.                                 z = dx;
  464.                                 dx = dy;
  465.                                 dy = z;
  466.                                 ch = 1;
  467.                         }
  468.                         else
  469.                         {
  470.                                 ch = 0;
  471.                         }
  472.                         e = 2*dy-dx;
  473.                         i = 1;
  474.  
  475.                         do
  476.                         {
  477.                                 DrawPixel(x,y,color);
  478.                                 while(e>=0)
  479.                                 {
  480.                                         if( ch==1 )     x = x+sx;
  481.                                                 else    y = y+sy;
  482.  
  483.                                         if( ch==1 )     y = y+sy;
  484.                                                 else    x = x+sx;
  485.  
  486.                                         e = e-2*dx;
  487.                                 }
  488.                                 if( ch==1 )             y = y+sy;
  489.                                         else            x = x+sx;
  490.  
  491.                                 e = e+2*dy;
  492.                                 i++;
  493.                         }
  494.                         while(i<=dx);
  495.                         DrawPixel(x, y,color);
  496.                         break;
  497.                 }
  498.         }
  499. }
  500.  
  501. //---------------------------------------------------------------------------------
  502. //                      libGUI function drawing rectangle on screen
  503. //---------------------------------------------------------------------------------
  504. void DrawRectangle(int x,int y,int size_x,int size_y,DWORD color)
  505. {
  506.  
  507.         if (size_x==0 || size_y==0) return;
  508.  
  509.         DrawHorizontalLine(x,x+size_x-1,y,color);
  510.         DrawVerticalLine(x+size_x-1,y,y+size_y-1,color);
  511.         DrawHorizontalLine(x,x+size_x-1,y+size_y-1,color);
  512.         DrawVerticalLine(x,y,y+size_y-1,color);
  513. }
  514.  
  515. //---------------------------------------------------------------------------------
  516. //                      libGUI function drawing finited rectangle on screen
  517. //---------------------------------------------------------------------------------
  518. void DrawRectangleFinit(struct FINITION *fin,int x,int y,int size_x,int size_y,DWORD color)
  519. {
  520.  
  521.         if (size_x==0 || size_y==0) return;
  522.  
  523.         DrawHorizontalLineFinit(fin,x,x+size_x-1,y,color);
  524.         DrawVerticalLineFinit(fin,x+size_x-1,y,y+size_y-1,color);
  525.         DrawHorizontalLineFinit(fin,x,x+size_x-1,y+size_y-1,color);
  526.         DrawVerticalLineFinit(fin,x,y,y+size_y-1,color);
  527. }
  528.  
  529. //---------------------------------------------------------------------------------
  530. //                      libGUI function drawing filled rectangle on screen
  531. //---------------------------------------------------------------------------------
  532. void DrawFilledRectangle(int x,int y,int size_x,int size_y,DWORD color)
  533. {
  534.         int     i,j;
  535.         int     x1,y1,x2,y2;
  536.  
  537.         if (size_x==0 || size_y==0) return;
  538.  
  539.         switch(screen.draw_output)
  540.         {
  541.                 case DRAW_OUTPUT_SCREEN:
  542.                 {
  543.                         x1=x;
  544.                         y1=y;
  545.                         x2=x+size_x-1;
  546.                         y2=y+size_y-1;
  547.                         if (y1>screen.size_y-1) {y1=screen.size_y-1;}
  548.                         if (y2>screen.size_y-1) {y2=screen.size_y-1;}
  549.                         if (x1>screen.size_x-1) {x1=screen.size_x-1;}
  550.                         if (x2>screen.size_x-1) {x2=screen.size_x-1;}
  551.                         if (y1<0) {y1=0;}
  552.                         if (y2<0) {y2=0;}
  553.                         if (x1<0) {x1=0;}
  554.                         if (x2<0) {x2=0;}
  555.  
  556.                         size_x=x2-x1+1;
  557.                         size_y=y2-y1+1;
  558.                         x1+=screen.x;
  559.                         y1+=screen.y;
  560.  
  561.                         gui_ksys_draw_filled_rectangle_window(x1,y1,size_x,size_y,color);
  562.                         break;
  563.                 }
  564.                 case DRAW_OUTPUT_BUFFER:
  565.                 {
  566.                         j=y;
  567.                         for(i=0;i<size_y;i++)
  568.                         {
  569.                                 DrawHorizontalLine(x,x+size_x-1,j,color);
  570.                                 j++;
  571.                         }
  572.                         break;
  573.                 }
  574.         }
  575. }
  576.  
  577. //---------------------------------------------------------------------------------
  578. //      libGUI function drawing filled gradient up and down rectangles on screen
  579. //---------------------------------------------------------------------------------
  580. void DrawGradientUpDownFilledRectangle(char flag_up,int x,int y,int sizex,int sizey,DWORD color_from,DWORD color_to)
  581. {
  582.         unsigned        char    r_f,g_f,b_f;
  583.         unsigned        char    r_t,g_t,b_t;
  584.         unsigned        char    r,g,b;
  585.         float                   f_r,f_g,f_b;
  586.         float                   d_r,d_g,d_b;
  587.         float                   div;
  588.         DWORD           color;
  589.         int                     i,j,dj;
  590.  
  591.         if (sizex==0 || sizey==0) return;
  592.  
  593.         color=color_from;
  594.         b_f=color & 0xff;
  595.         color=color >> 8;
  596.         g_f=color & 0xff;
  597.         color=color >> 8;
  598.         r_f=color & 0xff;
  599.  
  600.         color=color_to;
  601.         b_t=color & 0xff;
  602.         color=color >> 8;
  603.         g_t=color & 0xff;
  604.         color=color >> 8;
  605.         r_t=color & 0xff;
  606.  
  607.         div=sizey-1;
  608.         d_r=(float)(r_t-r_f);
  609.         d_r=d_r/div;
  610.         d_g=(float)(g_t-g_f);
  611.         d_g=d_g/div;
  612.         d_b=(float)(b_t-b_f);
  613.         d_b=d_b/div;
  614.  
  615.         f_r=r_f;
  616.         f_g=g_f;
  617.         f_b=b_f;
  618.  
  619.         r=r_f;
  620.         g=g_f;
  621.         b=b_f;
  622.  
  623.         if (flag_up==TRUE)
  624.         {
  625.                 j=y+sizey-1;
  626.                 dj=-1;
  627.         }
  628.         else
  629.         {
  630.                 j=y;
  631.                 dj=1;
  632.         }
  633.  
  634.  
  635.         for(i=0;i<sizey;i++)
  636.         {
  637.                 color=0;
  638.                 color=color | r;
  639.                 color=color << 8;
  640.                 color=color | g;
  641.                 color=color << 8;
  642.                 color=color | b;
  643.  
  644.                 DrawHorizontalLine(x,x+sizex-1,j,color);
  645.  
  646.                 f_r=f_r+d_r;
  647.                 f_g=f_g+d_g;
  648.                 f_b=f_b+d_b;
  649.  
  650.                 r=(char)f_r;
  651.                 g=(char)f_g;
  652.                 b=(char)f_b;
  653.  
  654.                 j=j+dj;
  655.         }
  656.  
  657. }
  658.  
  659. //---------------------------------------------------------------------------------
  660. //      libGUI function drawing filled gradient left and right rectangles on screen
  661. //---------------------------------------------------------------------------------
  662. void DrawGradientLeftRightFilledRectangle(char flag_left,int x,int y,int sizex,int sizey,DWORD color_from,DWORD color_to)
  663. {
  664.         unsigned        char    r_f,g_f,b_f;
  665.         unsigned        char    r_t,g_t,b_t;
  666.         unsigned        char    r,g,b;
  667.         float                   f_r,f_g,f_b;
  668.         float                   d_r,d_g,d_b;
  669.         float                   div;
  670.         DWORD           color;
  671.         int                     i,j,dj;
  672.  
  673.         if (sizex==0 || sizey==0) return;
  674.  
  675.         color=color_from;
  676.         b_f=color & 0xff;
  677.         color=color >> 8;
  678.         g_f=color & 0xff;
  679.         color=color >> 8;
  680.         r_f=color & 0xff;
  681.  
  682.         color=color_to;
  683.         b_t=color & 0xff;
  684.         color=color >> 8;
  685.         g_t=color & 0xff;
  686.         color=color >> 8;
  687.         r_t=color & 0xff;
  688.  
  689.         div=sizex-1;
  690.         d_r=(float)(r_t-r_f);
  691.         d_r=d_r/div;
  692.         d_g=(float)(g_t-g_f);
  693.         d_g=d_g/div;
  694.         d_b=(float)(b_t-b_f);
  695.         d_b=d_b/div;
  696.  
  697.         f_r=r_f;
  698.         f_g=g_f;
  699.         f_b=b_f;
  700.  
  701.         r=r_f;
  702.         g=g_f;
  703.         b=b_f;
  704.  
  705.         if (flag_left==TRUE)
  706.         {
  707.                 j=x;
  708.                 dj=1;
  709.         }
  710.         else
  711.         {
  712.                 j=x+sizex-1;
  713.                 dj=-1;
  714.         }
  715.  
  716.         for(i=0;i<sizex;i++)
  717.         {
  718.                 color=0;
  719.                 color=color | r;
  720.                 color=color << 8;
  721.                 color=color | g;
  722.                 color=color << 8;
  723.                 color=color | b;
  724.  
  725.                 DrawVerticalLine(j,y,y+sizey-1,color);
  726.  
  727.                 f_r=f_r+d_r;
  728.                 f_g=f_g+d_g;
  729.                 f_b=f_b+d_b;
  730.  
  731.                 r=(char)f_r;
  732.                 g=(char)f_g;
  733.                 b=(char)f_b;
  734.  
  735.                 j=j+dj;
  736.         }
  737.  
  738. }
  739.  
  740. //---------------------------------------------------------------------------------
  741. //                      libGUI function drawing circle on screen
  742. //---------------------------------------------------------------------------------
  743. void DrawCircle(int xc, int yc, int r,DWORD color)
  744. {
  745.         int x;
  746.         int y;
  747.         int d;
  748.  
  749.         x = 0;
  750.         y = r;
  751.         d = 3-2*r;
  752.         while(y>=x)
  753.         {
  754.                 DrawPixel(x+xc,y+yc,color);
  755.                 DrawPixel(x+xc,-y+yc,color);
  756.                 DrawPixel(-x+xc,y+yc,color);
  757.                 DrawPixel(-x+xc,-y+yc,color);
  758.                 DrawPixel(y+xc,x+yc,color);
  759.                 DrawPixel(y+xc,-x+yc,color);
  760.                 DrawPixel(-y+xc,x+yc,color);
  761.                 DrawPixel(-y+xc,-x+yc,color);
  762.                 if( d<0 )
  763.                 {
  764.                         d = d+4*x+6;
  765.                 }
  766.                 else
  767.                 {
  768.                         d = d+4*(x-y)+10;
  769.                         y--;
  770.                 }
  771.                 x++;
  772.         }
  773. }
  774.  
  775. //---------------------------------------------------------------------------------
  776. //              libGUI function drawing circle on screen with finition
  777. //---------------------------------------------------------------------------------
  778. void DrawCircleFinit(struct FINITION *fin,int xc, int yc, int r,DWORD color)
  779. {
  780.         int x;
  781.         int y;
  782.         int d;
  783.  
  784.         x = 0;
  785.         y = r;
  786.         d = 3-2*r;
  787.         while(y>=x)
  788.         {
  789.                 DrawPixelFinit(fin,x+xc,y+yc,color);
  790.                 DrawPixelFinit(fin,x+xc,-y+yc,color);
  791.                 DrawPixelFinit(fin,-x+xc,y+yc,color);
  792.                 DrawPixelFinit(fin,-x+xc,-y+yc,color);
  793.                 DrawPixelFinit(fin,y+xc,x+yc,color);
  794.                 DrawPixelFinit(fin,y+xc,-x+yc,color);
  795.                 DrawPixelFinit(fin,-y+xc,x+yc,color);
  796.                 DrawPixelFinit(fin,-y+xc,-x+yc,color);
  797.                 if( d<0 )
  798.                 {
  799.                         d = d+4*x+6;
  800.                 }
  801.                 else
  802.                 {
  803.                         d = d+4*(x-y)+10;
  804.                         y--;
  805.                 }
  806.                 x++;
  807.         }
  808. }
  809.  
  810. //---------------------------------------------------------------------------------
  811. //              libGUI function drawing filled circle on screen
  812. //---------------------------------------------------------------------------------
  813. void DrawFilledCircle(int xc, int yc, int r,DWORD color)
  814. {
  815.         int             xl,yu,xr,yd;
  816.         int             i,j;
  817.         DWORD   pixcolor;
  818.  
  819.         DrawCircle(xc,yc,r,color);
  820.  
  821.         yu=yc;
  822.         yd=yc;
  823.         for(i=0;i<r;i++)
  824.         {
  825.                 xl=xc;
  826.                 xr=xc+1;
  827.                 j=0;
  828.                 //fill left up
  829.                 while((pixcolor=GetColorPixel(xl,yu))!=color)
  830.                 {
  831.                         DrawPixel(xl,yu,color);
  832.                         xl--;
  833.                         j++;
  834.                         if (j>r) break;
  835.                 }
  836.                 j=0;
  837.                 //fill right up
  838.                 while((pixcolor=GetColorPixel(xr,yu))!=color)
  839.                 {
  840.                         DrawPixel(xr,yu,color);
  841.                         xr++;
  842.                         j++;
  843.                         if (j>r) break;
  844.                 }
  845.  
  846.                 xl=xc;
  847.                 xr=xc+1;
  848.                 j=0;
  849.                 //fill left down
  850.                 while((pixcolor=GetColorPixel(xl,yd))!=color)
  851.                 {
  852.                         DrawPixel(xl,yd,color);
  853.                         xl--;
  854.                         j++;
  855.                         if (j>r) break;
  856.                 }
  857.                 j=0;
  858.                 //fill right down
  859.                 while((pixcolor=GetColorPixel(xr,yd))!=color)
  860.                 {
  861.                         DrawPixel(xr,yd,color);
  862.                         xr++;
  863.                         j++;
  864.                         if (j>r) break;
  865.                 }
  866.                 yu--;
  867.                 yd++;
  868.         }
  869. }
  870.  
  871. //---------------------------------------------------------------------------------
  872. //      libGUI function drawing filled circle on screen with finition
  873. //---------------------------------------------------------------------------------
  874. void DrawFilledCircleFinit(struct FINITION *fin,int xc, int yc, int r,DWORD color)
  875. {
  876.         int             xl,yu,xr,yd;
  877.         int             i,j;
  878.         DWORD   pixcolor;
  879.  
  880.         DrawCircleFinit(fin,xc,yc,r,color);
  881.  
  882.         yu=yc;
  883.         yd=yc;
  884.         for(i=0;i<r;i++)
  885.         {
  886.                 xl=xc;
  887.                 xr=xc+1;
  888.                 //fill left up
  889.                 for(j=0;j<r;j++)
  890.                 {
  891.                         if (xl>=fin->x && xl<=fin->x+fin->sizex &&
  892.                                 yu>=fin->y && yu<=fin->y+fin->sizey)
  893.                         {
  894.                                 pixcolor=GetColorPixel(xl,yu);
  895.                                 if (pixcolor!=color)    DrawPixel(xl,yu,color);
  896.                                         else break;
  897.                         }
  898.                         xl--;
  899.                 }
  900.                 //fill right up
  901.                 for(j=0;j<r;j++)
  902.                 {
  903.                         if (xr>=fin->x && xr<=fin->x+fin->sizex &&
  904.                                 yu>=fin->y && yu<=fin->y+fin->sizey)
  905.                         {
  906.                                 pixcolor=GetColorPixel(xr,yu);
  907.                                 if (pixcolor!=color)    DrawPixel(xr,yu,color);
  908.                                         else break;
  909.                         }
  910.                         xr++;
  911.                 }
  912.  
  913.                 xl=xc;
  914.                 xr=xc+1;
  915.                 //fill left down
  916.                 for(j=0;j<r;j++)
  917.                 {
  918.                         if (xl>=fin->x && xl<=fin->x+fin->sizex &&
  919.                                 yd>=fin->y && yd<=fin->y+fin->sizey)
  920.                         {
  921.                                 pixcolor=GetColorPixel(xl,yd);
  922.                                 if (pixcolor!=color)    DrawPixel(xl,yd,color);
  923.                                         else break;
  924.                         }
  925.                         xl--;
  926.                 }
  927.                 //fill right down
  928.                 for(j=0;j<r;j++)
  929.                 {
  930.                         if (xr>=fin->x && xr<=fin->x+fin->sizex &&
  931.                                 yd>=fin->y && yd<=fin->y+fin->sizey)
  932.                         {
  933.                                 pixcolor=GetColorPixel(xr,yd);
  934.                                 if (pixcolor!=color)    DrawPixel(xr,yd,color);
  935.                                         else break;
  936.                         }
  937.                         xr++;
  938.                 }
  939.                 yu--;
  940.                 yd++;
  941.         }
  942. }
  943.  
  944. //---------------------------------------------------------------------------------
  945. //                      libGUI function drawing ellipse on screen
  946. //---------------------------------------------------------------------------------
  947. void DrawEllipse(int x,int y,int a,int b,DWORD color)
  948. {
  949.         int     col,i,row,bnew;
  950.         long    a_square,b_square,two_a_square,two_b_square,four_a_square,four_b_square,d;
  951.  
  952.         b_square=b*b;
  953.         a_square=a*a;
  954.         row=b;
  955.         col=0;
  956.         two_a_square=a_square<<1;
  957.         four_a_square=a_square<<2;
  958.         four_b_square=b_square<<2;
  959.         two_b_square=b_square<<1;
  960.         d=two_a_square*((row-1)*(row))+a_square+two_b_square*(1-a_square);
  961.         while(a_square*(row)>b_square*(col))
  962.         {
  963.                 DrawPixel(col+x,row+y,color);
  964.                 DrawPixel(col+x,y-row,color);
  965.                 DrawPixel(x-col,row+y,color);
  966.                 DrawPixel(x-col,y-row,color);
  967.  
  968.                 if (d>=0)
  969.                 {
  970.                         row--;
  971.                         d-=four_a_square*(row);
  972.                 }
  973.                 d+=two_b_square*(3+(col<<1));
  974.                 col++;
  975.         }
  976.  
  977.         d=two_b_square*(col+1)*col+two_a_square*(row*(row-2)+1)+(1-two_a_square)*b_square;
  978.         while ((row) + 1)
  979.         {
  980.                 DrawPixel(col+x, row+y, color);
  981.                 DrawPixel(col+x, y-row, color);
  982.                 DrawPixel(x-col, row+y, color);
  983.                 DrawPixel(x-col, y-row, color);
  984.  
  985.                 if (d<=0)
  986.                 {
  987.                         col++;
  988.                         d+=four_b_square*col;
  989.                 }
  990.                 row--;
  991.                 d+=two_a_square*(3-(row <<1));
  992.         }
  993. }
  994.  
  995. //---------------------------------------------------------------------------------
  996. //              libGUI function drawing ellipse on screen with finition
  997. //---------------------------------------------------------------------------------
  998. void DrawEllipseFinit(struct FINITION *fin,int x,int y,int a,int b,DWORD color)
  999. {
  1000.         int     col,i,row,bnew;
  1001.         long    a_square,b_square,two_a_square,two_b_square,four_a_square,four_b_square,d;
  1002.  
  1003.         b_square=b*b;
  1004.         a_square=a*a;
  1005.         row=b;
  1006.         col=0;
  1007.         two_a_square=a_square<<1;
  1008.         four_a_square=a_square<<2;
  1009.         four_b_square=b_square<<2;
  1010.         two_b_square=b_square<<1;
  1011.         d=two_a_square*((row-1)*(row))+a_square+two_b_square*(1-a_square);
  1012.  
  1013.         while(a_square*(row)>b_square*(col))
  1014.         {
  1015.                 DrawPixelFinit(fin,col+x,row+y,color);
  1016.                 DrawPixelFinit(fin,col+x,y-row,color);
  1017.                 DrawPixelFinit(fin,x-col,row+y,color);
  1018.                 DrawPixelFinit(fin,x-col,y-row,color);
  1019.  
  1020.                 if (d>=0)
  1021.                 {
  1022.                         row--;
  1023.                         d-=four_a_square*(row);
  1024.                 }
  1025.                 d+=two_b_square*(3+(col<<1));
  1026.                 col++;
  1027.         }
  1028.  
  1029.         d=two_b_square*(col+1)*col+two_a_square*(row*(row-2)+1)+(1-two_a_square)*b_square;
  1030.         while ((row) + 1)
  1031.         {
  1032.                 DrawPixelFinit(fin,col+x, row+y, color);
  1033.                 DrawPixelFinit(fin,col+x, y-row, color);
  1034.                 DrawPixelFinit(fin,x-col, row+y, color);
  1035.                 DrawPixelFinit(fin,x-col, y-row, color);
  1036.  
  1037.                 if (d<=0)
  1038.                 {
  1039.                         col++;
  1040.                         d+=four_b_square*col;
  1041.                 }
  1042.                 row--;
  1043.                 d+=two_a_square*(3-(row <<1));
  1044.         }
  1045. }
  1046.  
  1047. //---------------------------------------------------------------------------------
  1048. //              libGUI function drawing filled ellips on screen
  1049. //---------------------------------------------------------------------------------
  1050. void DrawFilledEllipse(int xc, int yc, int a,int b,DWORD color)
  1051. {
  1052.         int             xl,yu,xr,yd;
  1053.         int             i,j;
  1054.         DWORD   pixcolor;
  1055.  
  1056.         DrawEllipse(xc,yc,a,b,color);
  1057.  
  1058.         yu=yc;
  1059.         yd=yc;
  1060.         for(i=0;i<b;i++)
  1061.         {
  1062.                 xl=xc;
  1063.                 xr=xc+1;
  1064.                 j=0;
  1065.                 //fill left up
  1066.                 while((pixcolor=GetColorPixel(xl,yu))!=color)
  1067.                 {
  1068.                         DrawPixel(xl,yu,color);
  1069.                         xl--;
  1070.                         j++;
  1071.                         if (j>a) break;
  1072.                 }
  1073.                 j=0;
  1074.                 //fill right up
  1075.                 while((pixcolor=GetColorPixel(xr,yu))!=color)
  1076.                 {
  1077.                         DrawPixel(xr,yu,color);
  1078.                         xr++;
  1079.                         j++;
  1080.                         if (j>a) break;
  1081.                 }
  1082.  
  1083.                 xl=xc;
  1084.                 xr=xc+1;
  1085.                 j=0;
  1086.                 //fill left down
  1087.                 while((pixcolor=GetColorPixel(xl,yd))!=color)
  1088.                 {
  1089.                         DrawPixel(xl,yd,color);
  1090.                         xl--;
  1091.                         j++;
  1092.                         if (j>a) break;
  1093.                 }
  1094.                 j=0;
  1095.                 //fill right down
  1096.                 while((pixcolor=GetColorPixel(xr,yd))!=color)
  1097.                 {
  1098.                         DrawPixel(xr,yd,color);
  1099.                         xr++;
  1100.                         j++;
  1101.                         if (j>a) break;
  1102.                 }
  1103.                 yu--;
  1104.                 yd++;
  1105.         }
  1106. }
  1107.  
  1108. //---------------------------------------------------------------------------------
  1109. //      libGUI function drawing filled circle on screen with finition
  1110. //---------------------------------------------------------------------------------
  1111. void DrawFilledEllipseFinit(struct FINITION *fin,int xc, int yc, int a,int b,DWORD color)
  1112. {
  1113.         int             xl,yu,xr,yd;
  1114.         int             i,j;
  1115.         DWORD   pixcolor;
  1116.  
  1117.         DrawEllipseFinit(fin,xc,yc,a,b,color);
  1118.  
  1119.         yu=yc;
  1120.         yd=yc;
  1121.         for(i=0;i<b;i++)
  1122.         {
  1123.                 xl=xc;
  1124.                 xr=xc+1;
  1125.                 //fill left up
  1126.                 for(j=0;j<a;j++)
  1127.                 {
  1128.                         if (xl>=fin->x && xl<=fin->x+fin->sizex &&
  1129.                                 yu>=fin->y && yu<=fin->y+fin->sizey)
  1130.                         {
  1131.                                 pixcolor=GetColorPixel(xl,yu);
  1132.                                 if (pixcolor!=color)    DrawPixel(xl,yu,color);
  1133.                                         else break;
  1134.                         }
  1135.                         xl--;
  1136.                 }
  1137.                 //fill right up
  1138.                 for(j=0;j<a;j++)
  1139.                 {
  1140.                         if (xr>=fin->x && xr<=fin->x+fin->sizex &&
  1141.                                 yu>=fin->y && yu<=fin->y+fin->sizey)
  1142.                         {
  1143.                                 pixcolor=GetColorPixel(xr,yu);
  1144.                                 if (pixcolor!=color)    DrawPixel(xr,yu,color);
  1145.                                         else break;
  1146.                         }
  1147.                         xr++;
  1148.                 }
  1149.  
  1150.                 xl=xc;
  1151.                 xr=xc+1;
  1152.                 //fill left down
  1153.                 for(j=0;j<a;j++)
  1154.                 {
  1155.                         if (xl>=fin->x && xl<=fin->x+fin->sizex &&
  1156.                                 yd>=fin->y && yd<=fin->y+fin->sizey)
  1157.                         {
  1158.                                 pixcolor=GetColorPixel(xl,yd);
  1159.                                 if (pixcolor!=color)    DrawPixel(xl,yd,color);
  1160.                                         else break;
  1161.                         }
  1162.                         xl--;
  1163.                 }
  1164.                 //fill right down
  1165.                 for(j=0;j<a;j++)
  1166.                 {
  1167.                         if (xr>=fin->x && xr<=fin->x+fin->sizex &&
  1168.                                 yd>=fin->y && yd<=fin->y+fin->sizey)
  1169.                         {
  1170.                                 pixcolor=GetColorPixel(xr,yd);
  1171.                                 if (pixcolor!=color)    DrawPixel(xr,yd,color);
  1172.                                         else break;
  1173.                         }
  1174.                         xr++;
  1175.                 }
  1176.                 yu--;
  1177.                 yd++;
  1178.         }
  1179. }
  1180.  
  1181. //---------------------------------------------------------------------------------
  1182. //              libGUI function drawing image on screen
  1183. //---------------------------------------------------------------------------------
  1184. void    DrawImage(int x,int y,int sizex,int sizey,char bits_per_pixel,char *img)
  1185. {
  1186.         char                    r,g,b;
  1187.         int                     i,j,countx,county;
  1188.         int                     x2,y2;
  1189.         DWORD                   pitch_src,pitch_screen,add_src,add_screen;
  1190.         char                    *ptr_src,*ptr_screen,ptr_max;
  1191.         char                    *ptr_src2,*ptr_screen2;
  1192.         DWORD                   *ptr_src3;
  1193.  
  1194.         if (img==NULL)  return;
  1195.         if (x>screen.size_x-1) return;
  1196.         if (y>screen.size_y-1) return;
  1197.  
  1198.         x2=x+sizex-1;
  1199.         y2=y+sizey-1;
  1200.  
  1201.  
  1202.         if (y2>screen.size_y-1) {y2=screen.size_y-1;}
  1203.         if (x2>screen.size_x-1) {x2=screen.size_x-1;}
  1204.         if (y<0) y=0;
  1205.         if (y2<0) y2=0;
  1206.         if (x<0) x=0;
  1207.         if (x2<0) x2=0;
  1208.  
  1209.         countx=x2-x+1;
  1210.         county=y2-y+1;
  1211.  
  1212.         switch(screen.draw_output)
  1213.         {
  1214.                 case DRAW_OUTPUT_SCREEN:
  1215.                 {
  1216.                         x+=screen.x;
  1217.                         y+=screen.y;
  1218.  
  1219.                         switch(screen.bits_per_pixel)
  1220.                         {
  1221.                                 case 32:
  1222.                                 case 24:
  1223.                                 {
  1224.                                         switch(bits_per_pixel)
  1225.                                         {//check bits per pixel in picture
  1226.                                                 case 32:
  1227.                                                 {//convert 32 bit image to 24 bit image
  1228.                                                         j=sizex*sizey;
  1229.                                                         ptr_src=img;
  1230.                                                         ptr_screen=malloc(j*3);
  1231.                                                         ptr_screen2=ptr_screen;
  1232.                                                         for(i=0;i<j;i++)
  1233.                                                         {
  1234.                                                                 *(char*)ptr_screen=*(char*)ptr_src;
  1235.                                                                 *((char*)ptr_screen+1)=*((char*)ptr_src+1);
  1236.                                                                 *((char*)ptr_screen+2)=*((char*)ptr_src+2);
  1237.  
  1238.                                                                 ptr_src+=4;
  1239.                                                                 ptr_screen+=3;
  1240.                                                         }
  1241.                                                         gui_ksys_put_image_window(ptr_screen2,x,y,countx,county);
  1242.                                                         free(ptr_screen2);
  1243.                                                         break;
  1244.                                                 }
  1245.                                                 case 24:
  1246.                                                 {
  1247.                                                         gui_ksys_put_image_window(img,x,y,countx,county);
  1248.                                                         break;
  1249.                                                 }
  1250.                                         }
  1251.                                         break;
  1252.                                 }
  1253.                                 default: break;
  1254.                         }
  1255.                         break;
  1256.                 }
  1257.                 case DRAW_OUTPUT_BUFFER:
  1258.                 {
  1259.                         switch(screen.bits_per_pixel)
  1260.                         {
  1261.                                 case 24:
  1262.                                 {//check source image resolution
  1263.                                         switch(bits_per_pixel)
  1264.                                         {
  1265.                                                 case 32://display 32 bit image in 24 bit mode
  1266.                                                 {//convert and draw 32 bit image in 24 bit buffer
  1267.                                                         ptr_screen=screen.buffer+(screen.size_x*y+x)*3;
  1268.                                                         add_screen=(screen.size_x-countx)*3;
  1269.                                                         ptr_src=img;
  1270.                                                         //copy line of byte with size x
  1271.                                                         for(i=0;i<county;i++)
  1272.                                                         {
  1273.                                                                 for(j=0;j<countx;j++)
  1274.                                                                 {
  1275.                                                                         *(char*)ptr_screen=*(char*)ptr_src;
  1276.                                                                         *((char*)ptr_screen+1)=*((char*)ptr_src+1);
  1277.                                                                         *((char*)ptr_screen+2)=*((char*)ptr_src+2);
  1278.                
  1279.                                                                         ptr_src+=4;
  1280.                                                                         ptr_screen+=3;
  1281.                                                                 }
  1282.                                                                 ptr_screen+=add_screen;
  1283.                                                         }
  1284.                                                         break;
  1285.                                                 }
  1286.                                                 case 24:
  1287.                                                 {//display 24 bit image in 24 bit buffer
  1288.                                                         ptr_screen=screen.buffer+(screen.size_x*y+x)*3;
  1289.                                                         add_screen=screen.size_x*3;
  1290.                                                         add_src=countx*3;
  1291.  
  1292.                                                         //copy line of byte with size x
  1293.                                                         for(i=0;i<county;i++)
  1294.                                                         {
  1295.                                                                 memmove(ptr_screen,img,add_src);
  1296.                                                                 ptr_screen+=add_screen;
  1297.                                                                 img+=add_src;
  1298.                                                         }
  1299.                                                         break;
  1300.                                                 }
  1301.                                                 default: break;
  1302.                                         }
  1303.                                         break;
  1304.                                 }
  1305.                                 case 32:
  1306.                                 {       //check source image resolution
  1307.                                         switch(bits_per_pixel)
  1308.                                         {
  1309.                                                 case 32:
  1310.                                                 {//display 32 bit image in 32 bit mode
  1311.                                                         ptr_screen=screen.buffer+(screen.size_x*y+x)*4;
  1312.                                                         add_screen=screen.size_x*4;
  1313.                                                         add_src=countx*4;
  1314.  
  1315.                                                         //copy line of byte with size x
  1316.                                                         for(i=0;i<county;i++)
  1317.                                                         {
  1318.                                                                 memmove(ptr_screen,img,add_src);
  1319.                                                                 ptr_screen+=add_screen;
  1320.                                                                 img+=add_src;
  1321.                                                         }
  1322.  
  1323.                                                         break;
  1324.                                                 }
  1325.                                                 case 24://display 24 bit image in 32 bit mode
  1326.                                                 {
  1327.                                                         ptr_screen=screen.buffer+(screen.size_x*y+x)*4;
  1328.                                                         add_screen=(screen.size_x-countx)*4;
  1329.                                                         ptr_src=img;
  1330.                                                         //copy line of byte with size x
  1331.                                                         for(i=0;i<county;i++)
  1332.                                                         {
  1333.                                                                 for(j=0;j<countx;j++)
  1334.                                                                 {
  1335.                                                                         *(char*)ptr_screen=*(char*)ptr_src;
  1336.                                                                         *((char*)ptr_screen+1)=*((char*)ptr_src+1);
  1337.                                                                         *((char*)ptr_screen+2)=*((char*)ptr_src+2);
  1338.                
  1339.                                                                         ptr_src+=3;
  1340.                                                                         ptr_screen+=4;
  1341.                                                                 }
  1342.                                                                 ptr_screen+=add_screen;
  1343.                                                         }
  1344.                                                         break;
  1345.                                                 }
  1346.                                                 default: break;
  1347.                                         }
  1348.                                         default: break;
  1349.                                 }
  1350.                         }
  1351.                 }
  1352.         }
  1353. }
  1354.  
  1355. //---------------------------------------------------------------------------------
  1356. //      libGUI function drawing image on screen with finition
  1357. //---------------------------------------------------------------------------------
  1358. void    DrawImageFinit(finition_t *fin,int x,int y,int sizex,int sizey,char bits_per_pixel,char *img)
  1359. {
  1360.         int             x1,y1,x2,y2,sx,sy;
  1361.         int             xmin,xmax,ymin,ymax;
  1362.         int             countline,countx,county,i,j;
  1363.         DWORD   pitch_src,add_src;
  1364.         char            *ptr_dest,*ptr_src;
  1365.         char            bytes_per_pixel;
  1366.         char            *buf;
  1367.  
  1368.         xmin=fin->x;
  1369.         xmax=fin->x+fin->sizex-1;
  1370.         ymin=fin->y;
  1371.         ymax=fin->y+fin->sizey-1;
  1372.  
  1373.         x1=x;
  1374.         y1=y;
  1375.         x2=x1+sizex-1;
  1376.         y2=y1+sizey-1;
  1377.  
  1378.         if (x2<xmin) return;
  1379.         if (x1>xmax) return;
  1380.         if (y2<ymin) return;
  1381.         if (y1>ymax) return;
  1382.  
  1383.         if (x1>=xmin && x2<=xmax && y1>=ymin && y2<=ymax)
  1384.         {
  1385.                 DrawImage(x,y,sizex,sizey,bits_per_pixel,img);
  1386.                 return;
  1387.         }
  1388.  
  1389.         //finit x coordinates and sizex
  1390.         sx=x1-xmin;
  1391.  
  1392.         if (sx>=0)
  1393.         {
  1394.                 if (x2>xmax) x2=xmax;
  1395.         }
  1396.         else
  1397.         {
  1398.                 x1=xmin;
  1399.                 if (x2>xmax) x2=xmax;
  1400.         }
  1401.  
  1402.         //finit y coordinates and sizey
  1403.         sy=y1-ymin;
  1404.  
  1405.         if (sy>=0)
  1406.         {
  1407.                 if (y2>ymax) y2=ymax;
  1408.         }
  1409.         else
  1410.         {
  1411.                 y1=ymin;
  1412.                 if (y2>ymax) y2=ymax;
  1413.         }
  1414.         countx=x2-x1+1;
  1415.         county=y2-y1+1;
  1416.  
  1417.         //cut finited rectangle from image and move them into buffer
  1418.  
  1419.         bytes_per_pixel=bits_per_pixel >> 3;
  1420.         buf=malloc(countx*county*bytes_per_pixel);
  1421.         ptr_dest=buf;
  1422.  
  1423.         pitch_src=sizex*bytes_per_pixel;
  1424.         ptr_src=img+pitch_src*(y1-y)+(x1-x)*bytes_per_pixel;
  1425.         add_src=sizex*bytes_per_pixel;
  1426.         countline=countx*bytes_per_pixel;
  1427.  
  1428.         switch(bits_per_pixel)
  1429.         {
  1430.                 case 32:
  1431.                 case 24:
  1432.                 case 16:
  1433.                 case 8:
  1434.                 {
  1435.                         for(i=0;i<county;i++)
  1436.                         {
  1437.                                 memmove(ptr_dest,ptr_src,countline);
  1438.                                 ptr_src+=add_src;
  1439.                                 ptr_dest+=countline;
  1440.                         }
  1441.                         break;
  1442.                 }
  1443.                 default: break;
  1444.         }
  1445.         //draw cutted by finition image
  1446.         DrawImage(x1,y1,countx,county,bits_per_pixel,buf);
  1447.         free(buf);
  1448. }
  1449.  
  1450. //---------------------------------------------------------------------------------
  1451. //                              libGUI function draw
  1452. //---------------------------------------------------------------------------------
  1453. void Draw(struct FINITION *finition,int tool_name,...)
  1454. {
  1455.         va_list arguments;
  1456.         char            *img;
  1457.         char            first,second,bits_per_pixel;
  1458.         int             xmin,xmax,ymin,ymax;
  1459.         int             radius;
  1460.         int             x,y,x2,y2,x_i,y_i;
  1461.         int             sizex,sizey,sx,sy;
  1462.         float           x_l1,y_l1,x_l2,y_l2,k,b;
  1463.         DWORD   color,color_from,color_to;
  1464.  
  1465.         arguments=(va_list)&tool_name+sizeof(int);
  1466.  
  1467.         xmin=finition->x;
  1468.         xmax=finition->x+finition->sizex-1;
  1469.         ymin=finition->y;
  1470.         ymax=finition->y+finition->sizey-1;
  1471.  
  1472.         switch(tool_name)
  1473.         {
  1474.                 //tool Pixel
  1475.                 case TOOL_PIXEL:
  1476.                 {
  1477.                         x=va_arg(arguments,int);
  1478.                         y=va_arg(arguments,int);
  1479.                         color=va_arg(arguments,DWORD);
  1480.  
  1481.                         if (finition->flags & FINITION_ON)
  1482.                         {
  1483.                                 if (x>=finition->x && x<=finition->x+finition->sizex
  1484.                                         && y>=finition->y && y<=finition->y+finition->sizey)
  1485.                                 {       //pixel inside finition arrea
  1486.                                         DrawPixel(x,y,color);
  1487.                                 }
  1488.                         }
  1489.                         else
  1490.                         {       //no finition
  1491.                                 DrawPixel(x,y,color);
  1492.                         }
  1493.                         break;
  1494.                 }
  1495.                 //tool Line
  1496.                 case TOOL_LINE:
  1497.                 {
  1498.                         x=va_arg(arguments,int);
  1499.                         y=va_arg(arguments,int);
  1500.                         x2=va_arg(arguments,int);
  1501.                         y2=va_arg(arguments,int);
  1502.                         color=va_arg(arguments,DWORD);
  1503.  
  1504.                         if (finition->flags & FINITION_ON)
  1505.                         {
  1506.                                 sizex=abs(x2-x);
  1507.                                 sizey=abs(y2-y);
  1508.  
  1509.                                 if (CheckCrossRectangles(finition->x,finition->y,finition->sizex,
  1510.                                                                 finition->sizey,x,y,sizex,sizey)==FALSE) break;
  1511.  
  1512.                                 if (x>=finition->x && x<=finition->x+finition->sizex &&
  1513.                                         y>=finition->y && y<=finition->y+finition->sizey &&
  1514.                                         x2>=finition->x && x2<=finition->x+finition->sizex &&
  1515.                                         y2>=finition->y && y2<=finition->y+finition->sizey)
  1516.                                 {
  1517.                                         //line inside finition arrea
  1518.                                         DrawLine(x,y,x2,y2,color);
  1519.                                         break;
  1520.                                 }
  1521.  
  1522.  
  1523.                                 if (x==x2) break;
  1524.  
  1525.                                 //find coefficients of line
  1526.                                 x_l1=x;
  1527.                                 y_l1=y;
  1528.                                 x_l2=x2;
  1529.                                 y_l2=y2;
  1530.                                 k=(y_l1-y_l2)/(x_l1-x_l2);
  1531.                                 b=(y_l2*x_l1-y_l1*x_l2)/(x_l1-x_l2);
  1532.  
  1533.                                 sx=x2-x;//vectore x
  1534.                                 sy=y2-y;//vectore y
  1535.  
  1536.                                 if (x>=finition->x && x<=finition->x+finition->sizex &&
  1537.                                         y>=finition->y && y<=finition->y+finition->sizey)
  1538.                                 {       //point x,y inside finition arrea
  1539.                                         //check cross with left vertical line of finition
  1540.                                         y_l1=k*finition->x+b;
  1541.                                         y_i=(int)y_l1;
  1542.                                         if (y_i>=finition->y && y_i<=finition->y+finition->sizey && sx<0)
  1543.                                         {       //first point for finited line
  1544.                                                 x2=finition->x;
  1545.                                                 y2=y_i;
  1546.                                                 DrawLine(x,y,x2,y2,color);
  1547.                                                 break;
  1548.                                         }
  1549.                                         //check cross with up horizontal line of finition
  1550.                                         x_l1=(finition->y-b)/k;
  1551.                                         x_i=(int)x_l1;
  1552.                                         if (x_i>=finition->x && x_i<=finition->x+finition->sizex && sy<0)
  1553.                                         {
  1554.                                                 x2=x_i;
  1555.                                                 y2=finition->y;
  1556.                                                 DrawLine(x,y,x2,y2,color);
  1557.                                                 break;
  1558.                                         }
  1559.                                         //check cross with right vertical line of finition
  1560.                                         y_l1=k*(finition->x+finition->sizex)+b;
  1561.                                         y_i=(int)y_l1;
  1562.                                         if (y_i>=finition->y && y_i<=finition->y+finition->sizey && sx>0)
  1563.                                         {
  1564.                                                 x2=finition->x+finition->sizex;
  1565.                                                 y2=y_i;
  1566.                                                 DrawLine(x,y,x2,y2,color);
  1567.                                                 break;
  1568.                                         }
  1569.                                         //check cross with down horizontal line of finition
  1570.                                         x_l1=((finition->y+finition->sizey)-b)/k;
  1571.                                         x_i=(int)x_l1;
  1572.                                         if (x_i>=finition->x && x_i<=finition->x+finition->sizex && sy>0)
  1573.                                         {
  1574.                                                 x2=x_i;
  1575.                                                 y2=finition->y+finition->sizey;
  1576.                                                 DrawLine(x,y,x2,y2,color);
  1577.                                                 break;
  1578.                                         }
  1579.                                 }
  1580.  
  1581.                                 if (x2>=finition->x && x2<=finition->x+finition->sizex &&
  1582.                                         y2>=finition->y && y2<=finition->y+finition->sizey)
  1583.                                 {       //point x,y inside finition arrea
  1584.                                         //check cross with left vertical line of finition
  1585.                                         y_l1=k*finition->x+b;
  1586.                                         y_i=(int)y_l1;
  1587.                                         if (y_i>=finition->y && y_i<=finition->y+finition->sizey && sx>0)
  1588.                                         {       //first point for finited line
  1589.                                                 x=finition->x;
  1590.                                                 y=y_i;
  1591.                                                 DrawLine(x,y,x2,y2,color);
  1592.                                                 break;
  1593.                                         }
  1594.                                         //check cross with up horizontal line of finition
  1595.                                         x_l1=(finition->y-b)/k;
  1596.                                         x_i=(int)x_l1;
  1597.                                         if (x_i>=finition->x && x_i<=finition->x+finition->sizex && sy>0)
  1598.                                         {
  1599.                                                 x=x_i;
  1600.                                                 y=finition->y;
  1601.                                                 DrawLine(x,y,x2,y2,color);
  1602.                                                 break;
  1603.                                         }
  1604.                                         //check cross with right vertical line of finition
  1605.                                         y_l1=k*(finition->x+finition->sizex)+b;
  1606.                                         y_i=(int)y_l1;
  1607.                                         if (y_i>=finition->y && y_i<=finition->y+finition->sizey && sx<0)
  1608.                                         {
  1609.                                                 x=finition->x+finition->sizex;
  1610.                                                 y=y_i;
  1611.                                                 DrawLine(x,y,x2,y2,color);
  1612.                                                 break;
  1613.                                         }
  1614.                                         //check cross with down horizontal line of finition
  1615.                                         x_l1=((finition->y+finition->sizey)-b)/k;
  1616.                                         x_i=(int)x_l1;
  1617.                                         if (x_i>=finition->x && x_i<=finition->x+finition->sizex && sy<0)
  1618.                                         {
  1619.                                                 x=x_i;
  1620.                                                 y=finition->y+finition->sizey;
  1621.                                                 DrawLine(x,y,x2,y2,color);
  1622.                                                 break;
  1623.                                         }
  1624.                                 }
  1625.  
  1626.                                 first=FALSE;
  1627.                                 second=FALSE;
  1628.                                 //check cross with left vertical line of finition
  1629.                                 y_l1=k*finition->x+b;
  1630.                                 y_i=(int)y_l1;
  1631.                                 if (y_i>=finition->y && y_i<=finition->y+finition->sizey)
  1632.                                 {       //first point for finited line
  1633.                                         x=finition->x;
  1634.                                         y=y_i;
  1635.                                         first=TRUE;
  1636.                                 }
  1637.                                 //check cross with up horizontal line of finition
  1638.                                 x_l1=(finition->y-b)/k;
  1639.                                 x_i=(int)x_l1;
  1640.                                 if (x_i>=finition->x && x_i<=finition->x+finition->sizex)
  1641.                                 {
  1642.                                         if (first==FALSE)
  1643.                                         {
  1644.                                                 x=x_i;
  1645.                                                 y=finition->y;
  1646.                                         }
  1647.                                         else
  1648.                                         {
  1649.                                                 x2=x_i;
  1650.                                                 y2=finition->y;
  1651.                                                 second=TRUE;
  1652.                                         }
  1653.                                 }
  1654.                                 //check cross with right vertical line of finition
  1655.                                 y_l1=k*(finition->x+finition->sizex)+b;
  1656.                                 y_i=(int)y_l1;
  1657.                                 if (y_i>=finition->y && y_i<=finition->y+finition->sizey)
  1658.                                 {
  1659.                                         if (first==FALSE)
  1660.                                         {
  1661.                                                 x=finition->x+finition->sizex;
  1662.                                                 y=y_i;
  1663.                                         }
  1664.                                         else
  1665.                                         {
  1666.                                                 x2=finition->x+finition->sizex;
  1667.                                                 y2=y_i;
  1668.                                                 second=TRUE;
  1669.                                         }
  1670.                                 }
  1671.                                 //check cross with down horizontal line of finition
  1672.                                 x_l1=((finition->y+finition->sizey)-b)/k;
  1673.                                 x_i=(int)x_l1;
  1674.                                 if (x_i>=finition->x && x_i<=finition->x+finition->sizex)
  1675.                                 {
  1676.                                         if (first==FALSE)
  1677.                                         {
  1678.                                                 x=x_i;
  1679.                                                 y=finition->y+finition->sizey;
  1680.                                         }
  1681.                                         else
  1682.                                         {
  1683.                                                 x2=x_i;
  1684.                                                 y2=finition->y+finition->sizey;
  1685.                                                 second=TRUE;
  1686.                                         }
  1687.                                 }
  1688.  
  1689.                                 if (first==TRUE && second==TRUE)
  1690.                                 {
  1691.                                         //draw finited line
  1692.                                         DrawLine(x,y,x2,y2,color);
  1693.                                 }
  1694.                                 break;
  1695.  
  1696.                         }
  1697.                         else
  1698.                         {       //no finition
  1699.                                 DrawLine(x,y,x2,y2,color);
  1700.                         }
  1701.                         break;
  1702.                 }
  1703.                 //tool VerticalLine
  1704.                 case TOOL_VERTICAL_LINE:
  1705.                 {
  1706.                         x=va_arg(arguments,int);
  1707.                         y=va_arg(arguments,int);
  1708.                         y2=va_arg(arguments,int);
  1709.                         color=va_arg(arguments,DWORD);
  1710.  
  1711.                         if (finition->flags & FINITION_ON)
  1712.                         {
  1713.                                 DrawVerticalLineFinit(finition,x,y,y2,color);
  1714.                         }
  1715.                         else
  1716.                         {
  1717.                                 DrawVerticalLine(x,y,y2,color);
  1718.                         }
  1719.                         break;
  1720.                 }
  1721.                 //tool HorizontalLine
  1722.                 case TOOL_HORIZONTAL_LINE:
  1723.                 {
  1724.                         x=va_arg(arguments,int);
  1725.                         x2=va_arg(arguments,int);
  1726.                         y=va_arg(arguments,int);
  1727.                         color=va_arg(arguments,DWORD);
  1728.  
  1729.                         if (finition->flags & FINITION_ON)
  1730.                         {
  1731.                                 DrawHorizontalLineFinit(finition,x,x2,y,color);
  1732.                         }
  1733.                         else
  1734.                         {
  1735.                                 DrawHorizontalLine(x,x2,y,color);
  1736.                         }
  1737.                         break;
  1738.                 }
  1739.  
  1740.                 //tool Rectangle
  1741.                 case TOOL_RECTANGLE:
  1742.                 {
  1743.                         x=va_arg(arguments,int);
  1744.                         y=va_arg(arguments,int);
  1745.                         sizex=va_arg(arguments,int);
  1746.                         sizey=va_arg(arguments,int);
  1747.                         color=va_arg(arguments,DWORD);
  1748.  
  1749.                         if (finition->flags & FINITION_ON)
  1750.                         {
  1751.                                 x2=x+sizex-1;
  1752.                                 y2=y+sizey-1;
  1753.  
  1754.                                 if (x2<xmin) return;
  1755.                                 if (x>xmax) return;
  1756.                                 if (y2<ymin) return;
  1757.                                 if (y>ymax) return;
  1758.  
  1759.                                 DrawRectangleFinit(finition,x,y,sizex,sizey,color);
  1760.                         }
  1761.                         else
  1762.                         {
  1763.                                 DrawRectangle(x,y,sizex,sizey,color);
  1764.                         }
  1765.                         break;
  1766.                 }
  1767.                 //tool FilledRectangle
  1768.                 case TOOL_FILLED_RECTANGLE:
  1769.                 {
  1770.                         x=va_arg(arguments,int);
  1771.                         y=va_arg(arguments,int);
  1772.                         sizex=va_arg(arguments,int);
  1773.                         sizey=va_arg(arguments,int);
  1774.                         color=va_arg(arguments,DWORD);
  1775.  
  1776.                         if (finition->flags & FINITION_ON)
  1777.                         {
  1778.                                 x2=x+sizex-1;
  1779.                                 y2=y+sizey-1;
  1780.  
  1781.                                 if (x2<xmin) return;
  1782.                                 if (x>xmax) return;
  1783.                                 if (y2<ymin) return;
  1784.                                 if (y>ymax) return;
  1785.  
  1786.                                 //finit x coordinates and sizex
  1787.                                 sx=x-xmin;
  1788.  
  1789.                                 if (sx>=0)
  1790.                                 {
  1791.                                         if (x2>xmax) x2=xmax;
  1792.                                 }
  1793.                                 else
  1794.                                 {
  1795.                                         x=xmin;
  1796.                                         if (x2>xmax) x2=xmax;
  1797.                                 }
  1798.  
  1799.                                 //finit y coordinates and sizey
  1800.                                 sy=y-ymin;
  1801.  
  1802.                                 if (sy>=0)
  1803.                                 {
  1804.                                         if (y2>ymax) y2=ymax;
  1805.                                 }
  1806.                                 else
  1807.                                 {
  1808.                                         y=ymin;
  1809.                                         if (y2>ymax) y2=ymax;
  1810.                                 }
  1811.  
  1812.                                 sizex=x2-x+1;
  1813.                                 sizey=y2-y+1;
  1814.  
  1815.                                 DrawFilledRectangle(x,y,sizex,sizey,color);
  1816.                         }
  1817.                         else
  1818.                         {
  1819.                                 DrawFilledRectangle(x,y,sizex,sizey,color);
  1820.                         }
  1821.                         break;
  1822.                 }
  1823.                 //tool GradientUpFilledRectangle
  1824.                 case TOOL_GRADIENT_UP_FILLED_RECTANGLE:
  1825.                 {
  1826.                         x=va_arg(arguments,int);
  1827.                         y=va_arg(arguments,int);
  1828.                         sizex=va_arg(arguments,int);
  1829.                         sizey=va_arg(arguments,int);
  1830.                         color_from=va_arg(arguments,DWORD);
  1831.                         color_to=va_arg(arguments,DWORD);
  1832.  
  1833.                         if (finition->flags & FINITION_ON)
  1834.                         {
  1835.                                 x2=x+sizex-1;
  1836.                                 y2=y+sizey-1;
  1837.  
  1838.                                 if (x2<xmin) return;
  1839.                                 if (x>xmax) return;
  1840.                                 if (y2<ymin) return;
  1841.                                 if (y>ymax) return;
  1842.  
  1843.                                 //finit x coordinates and sizex
  1844.                                 sx=x-xmin;
  1845.  
  1846.                                 if (sx>=0)
  1847.                                 {
  1848.                                         if (x2>xmax) x2=xmax;
  1849.                                 }
  1850.                                 else
  1851.                                 {
  1852.                                         x=xmin;
  1853.                                         if (x2>xmax) x2=xmax;
  1854.                                 }
  1855.  
  1856.                                 //finit y coordinates and sizey
  1857.                                 sy=y-ymin;
  1858.  
  1859.                                 if (sy>=0)
  1860.                                 {
  1861.                                         if (y2>ymax) y2=ymax;
  1862.                                 }
  1863.                                 else
  1864.                                 {
  1865.                                         y=ymin;
  1866.                                         if (y2>ymax) y2=ymax;
  1867.                                 }
  1868.  
  1869.                                 sizex=x2-x+1;
  1870.                                 sizey=y2-y+1;
  1871.  
  1872.                                 DrawGradientUpDownFilledRectangle(TRUE,x,y,sizex,sizey,color_from,color_to);
  1873.                         }
  1874.                         else
  1875.                         {
  1876.                                 DrawGradientUpDownFilledRectangle(TRUE,x,y,sizex,sizey,color_from,color_to);
  1877.                         }
  1878.                         break;
  1879.                 }
  1880.                 //tool GradientDownFilledRectangle
  1881.                 case TOOL_GRADIENT_DOWN_FILLED_RECTANGLE:
  1882.                 {
  1883.                         x=va_arg(arguments,int);
  1884.                         y=va_arg(arguments,int);
  1885.                         sizex=va_arg(arguments,int);
  1886.                         sizey=va_arg(arguments,int);
  1887.                         color_from=va_arg(arguments,DWORD);
  1888.                         color_to=va_arg(arguments,DWORD);
  1889.  
  1890.                         if (finition->flags & FINITION_ON)
  1891.                         {
  1892.                                 x2=x+sizex-1;
  1893.                                 y2=y+sizey-1;
  1894.  
  1895.                                 if (x2<xmin) return;
  1896.                                 if (x>xmax) return;
  1897.                                 if (y2<ymin) return;
  1898.                                 if (y>ymax) return;
  1899.  
  1900.                                 //finit x coordinates and sizex
  1901.                                 sx=x-xmin;
  1902.  
  1903.                                 if (sx>=0)
  1904.                                 {
  1905.                                         if (x2>xmax) x2=xmax;
  1906.                                 }
  1907.                                 else
  1908.                                 {
  1909.                                         x=xmin;
  1910.                                         if (x2>xmax) x2=xmax;
  1911.                                 }
  1912.  
  1913.                                 //finit y coordinates and sizey
  1914.                                 sy=y-ymin;
  1915.  
  1916.                                 if (sy>=0)
  1917.                                 {
  1918.                                         if (y2>ymax) y2=ymax;
  1919.                                 }
  1920.                                 else
  1921.                                 {
  1922.                                         y=ymin;
  1923.                                         if (y2>ymax) y2=ymax;
  1924.                                 }
  1925.  
  1926.                                 sizex=x2-x+1;
  1927.                                 sizey=y2-y+1;
  1928.  
  1929.                                 DrawGradientUpDownFilledRectangle(FALSE,x,y,sizex,sizey,color_from,color_to);
  1930.                         }
  1931.                         else
  1932.                         {
  1933.                                 DrawGradientUpDownFilledRectangle(FALSE,x,y,sizex,sizey,color_from,color_to);
  1934.                         }
  1935.                         break;
  1936.                 }
  1937.                 //tool GradientLeftFilledRectangle
  1938.                 case TOOL_GRADIENT_LEFT_FILLED_RECTANGLE:
  1939.                 {
  1940.                         x=va_arg(arguments,int);
  1941.                         y=va_arg(arguments,int);
  1942.                         sizex=va_arg(arguments,int);
  1943.                         sizey=va_arg(arguments,int);
  1944.                         color_from=va_arg(arguments,DWORD);
  1945.                         color_to=va_arg(arguments,DWORD);
  1946.  
  1947.                         if (finition->flags & FINITION_ON)
  1948.                         {
  1949.                                 x2=x+sizex-1;
  1950.                                 y2=y+sizey-1;
  1951.  
  1952.                                 if (x2<xmin) return;
  1953.                                 if (x>xmax) return;
  1954.                                 if (y2<ymin) return;
  1955.                                 if (y>ymax) return;
  1956.  
  1957.                                 //finit x coordinates and sizex
  1958.                                 sx=x-xmin;
  1959.  
  1960.                                 if (sx>=0)
  1961.                                 {
  1962.                                         if (x2>xmax) x2=xmax;
  1963.                                 }
  1964.                                 else
  1965.                                 {
  1966.                                         x=xmin;
  1967.                                         if (x2>xmax) x2=xmax;
  1968.                                 }
  1969.  
  1970.                                 //finit y coordinates and sizey
  1971.                                 sy=y-ymin;
  1972.  
  1973.                                 if (sy>=0)
  1974.                                 {
  1975.                                         if (y2>ymax) y2=ymax;
  1976.                                 }
  1977.                                 else
  1978.                                 {
  1979.                                         y=ymin;
  1980.                                         if (y2>ymax) y2=ymax;
  1981.                                 }
  1982.  
  1983.                                 sizex=x2-x+1;
  1984.                                 sizey=y2-y+1;
  1985.  
  1986.                                 DrawGradientLeftRightFilledRectangle(TRUE,x,y,sizex,sizey,color_from,color_to);
  1987.                         }
  1988.                         else
  1989.                         {
  1990.                                 DrawGradientLeftRightFilledRectangle(TRUE,x,y,sizex,sizey,color_from,color_to);
  1991.                         }
  1992.                         break;
  1993.                 }
  1994.                 //tool GradientRightFilledRectangle
  1995.                 case TOOL_GRADIENT_RIGHT_FILLED_RECTANGLE:
  1996.                 {
  1997.                         x=va_arg(arguments,int);
  1998.                         y=va_arg(arguments,int);
  1999.                         sizex=va_arg(arguments,int);
  2000.                         sizey=va_arg(arguments,int);
  2001.                         color_from=va_arg(arguments,DWORD);
  2002.                         color_to=va_arg(arguments,DWORD);
  2003.  
  2004.                         if (finition->flags & FINITION_ON)
  2005.                         {
  2006.                                 x2=x+sizex-1;
  2007.                                 y2=y+sizey-1;
  2008.  
  2009.                                 if (x2<xmin) return;
  2010.                                 if (x>xmax) return;
  2011.                                 if (y2<ymin) return;
  2012.                                 if (y>ymax) return;
  2013.  
  2014.                                 //finit x coordinates and sizex
  2015.                                 sx=x-xmin;
  2016.  
  2017.                                 if (sx>=0)
  2018.                                 {
  2019.                                         if (x2>xmax) x2=xmax;
  2020.                                 }
  2021.                                 else
  2022.                                 {
  2023.                                         x=xmin;
  2024.                                         if (x2>xmax) x2=xmax;
  2025.                                 }
  2026.  
  2027.                                 //finit y coordinates and sizey
  2028.                                 sy=y-ymin;
  2029.  
  2030.                                 if (sy>=0)
  2031.                                 {
  2032.                                         if (y2>ymax) y2=ymax;
  2033.                                 }
  2034.                                 else
  2035.                                 {
  2036.                                         y=ymin;
  2037.                                         if (y2>ymax) y2=ymax;
  2038.                                 }
  2039.  
  2040.                                 sizex=x2-x+1;
  2041.                                 sizey=y2-y+1;
  2042.  
  2043.                                 DrawGradientLeftRightFilledRectangle(FALSE,x,y,sizex,sizey,color_from,color_to);
  2044.                         }
  2045.                         else
  2046.                         {
  2047.                                 DrawGradientLeftRightFilledRectangle(FALSE,x,y,sizex,sizey,color_from,color_to);
  2048.                         }
  2049.                         break;
  2050.                 }
  2051.                 //tool Circle
  2052.                 case TOOL_CIRCLE:
  2053.                 {
  2054.                         x=va_arg(arguments,int);
  2055.                         y=va_arg(arguments,int);
  2056.                         radius=va_arg(arguments,int);
  2057.                         color=va_arg(arguments,DWORD);
  2058.  
  2059.                         if (finition->flags & FINITION_ON)
  2060.                         {
  2061.                                 DrawCircleFinit(finition,x,y,radius,color);
  2062.                         }
  2063.                         else
  2064.                         {
  2065.                                 DrawCircle(x,y,radius,color);
  2066.                         }
  2067.                         break;
  2068.                 }
  2069.                 //tool FilledCircle
  2070.                 case TOOL_FILLED_CIRCLE:
  2071.                 {
  2072.                         x=va_arg(arguments,int);
  2073.                         y=va_arg(arguments,int);
  2074.                         radius=va_arg(arguments,int);
  2075.                         color=va_arg(arguments,DWORD);
  2076.  
  2077.                         if (finition->flags & FINITION_ON)
  2078.                         {
  2079.                                 DrawFilledCircleFinit(finition,x,y,radius,color);
  2080.                         }
  2081.                         else
  2082.                         {
  2083.                                 DrawFilledCircle(x,y,radius,color);
  2084.                         }
  2085.                         break;
  2086.                 }
  2087.                 //tool Ellipse
  2088.                 case TOOL_ELLIPSE:
  2089.                 {
  2090.                         x=va_arg(arguments,int);
  2091.                         y=va_arg(arguments,int);
  2092.                         sizex=va_arg(arguments,int);
  2093.                         sizey=va_arg(arguments,int);
  2094.                         color=va_arg(arguments,DWORD);
  2095.  
  2096.                         if (finition->flags & FINITION_ON)
  2097.                         {
  2098.                                 DrawEllipseFinit(finition,x,y,sizex,sizey,color);
  2099.                         }
  2100.                         else
  2101.                         {
  2102.                                 DrawEllipse(x,y,sizex,sizey,color);
  2103.                         }
  2104.                         break;
  2105.                 }
  2106.                 //tool FilledEllipse
  2107.                 case TOOL_FILLED_ELLIPSE:
  2108.                 {
  2109.                         x=va_arg(arguments,int);
  2110.                         y=va_arg(arguments,int);
  2111.                         sizex=va_arg(arguments,int);
  2112.                         sizey=va_arg(arguments,int);
  2113.                         color=va_arg(arguments,DWORD);
  2114.  
  2115.                         if (finition->flags & FINITION_ON)
  2116.                         {
  2117.                                 DrawFilledEllipseFinit(finition,x,y,sizex,sizey,color);
  2118.                         }
  2119.                         else
  2120.                         {
  2121.                                 DrawFilledEllipse(x,y,sizex,sizey,color);
  2122.                         }
  2123.                         break;
  2124.                 }
  2125.                 //tool Image
  2126.                 case TOOL_IMAGE:
  2127.                 {
  2128.                         x=va_arg(arguments,int);
  2129.                         y=va_arg(arguments,int);
  2130.                         sizex=va_arg(arguments,int);
  2131.                         sizey=va_arg(arguments,int);
  2132.                         bits_per_pixel=(char)va_arg(arguments,int);
  2133.                         img=va_arg(arguments,char*);
  2134.  
  2135.                         if (finition->flags & FINITION_ON)
  2136.                         {
  2137.                                 DrawImageFinit(finition,x,y,sizex,sizey,bits_per_pixel,img);
  2138.                         }
  2139.                         else
  2140.                         {
  2141.                                 DrawImage(x,y,sizex,sizey,bits_per_pixel,img);
  2142.                         }
  2143.                         break;
  2144.                 }
  2145.         }
  2146.         va_end(arguments);
  2147. }
  2148.  
  2149.  
  2150.