Page 151 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 151

Unit 9: Translation



                     #defineESC0x1b                                                               Notes
                     #defineALT_X0x2d
                     longsize=0;
                     voidfar*buffer2=0;
                     voidfar*buffer1=0;
                     voiddraw_pixelbackground()
                     {
                     inti,xpos,ypos,color;
                     intxmax=getmaxx();
                     intymax=getmaxy();
                     setbkcolor(BLUE);
                     setcolor(WHITE);
                     rectangle(0,0,xmax,ymax);
                     for(i=0;i<5000;i++)
                     {
                     xpos=rand()%xmax;
                     ypos=rand()%ymax;
                     color=rand()%12;
                     putpixel(xpos,ypos,color);
                     }
                     }
                     voiddraw_object(intleft,inttop,intright,intbottom)
                     {
                     size=imagesize(left,top,right,bottom);
                     buffer1=farmalloc(size);
                     buffer2=farmalloc(size);
                     getimage(left,top,right,bottom,buffer1);
                     rectangle(left,top,right,bottom);
                     line(left,top,right,bottom);
                     line(left,bottom,right,top);
                     }
                     voidmove_object(intleft,inttop,intright,intbottom,intdestx,intdesty)
                     {
                     intwidth=right-left;
                     intheight=bottom-top;
                     getimage(left,top,right,bottom,buffer2);
                     putimage(left,top,buffer1,COPY_PUT);
                     getimage(destx,desty,destx+width,desty+height,buffer1);
                     putimage(destx,desty,buffer2,COPY_PUT);
                     }
                     voidmain()
                     {


                                             LOVELY PROFESSIONAL UNIVERSITY                                   145
   146   147   148   149   150   151   152   153   154   155   156