Advertisement
nguyenvanquan7826

star

Aug 20th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. void star()
  2. {
  3.    
  4.     int x[5], y[5];
  5.     float goc = (float)-90*M_PI/180;    // xac dinh goc ban dau
  6.     int R = 100;
  7.     int x0 = getmaxx()/2, y0 = getmaxy()/2;
  8.     for (int i=0; i<5; i++)     // xac dinh toa do 5 dinh ngoi sao
  9.     {
  10.         x[i] = x0 + (int)(R*cos(goc)+0.5);
  11.         y[i] = y0 + (int)(R*sin(goc)+0.5);
  12.         goc += (float)72*M_PI/180;
  13.     }
  14.     for (int i=0, j = 4; i<5; i++)  // Ve cac duong thang noi canh ngoi sao
  15.     {
  16.         delay(DELAY);
  17.         lineBresenham(x[j],y[j],x[(j+2)%5],y[(j+2)%5]);
  18.         j = (j + 2)%5;
  19.     }
  20.    
  21.     int fun = 30;
  22.     delay(DELAY*fun); setcolor(color);  // dat mau cho ngoi sao.
  23.     delay(DELAY*fun); floodfill(x0,y0,color);       // to mau vung giua
  24.     delay(DELAY*fun); floodfill(x0, y0 - R/3 - 1,color);        // to mau canh tren
  25.     delay(DELAY*fun); floodfill(x0 - R/3 - 1, y0,color);        // to mau canh trai
  26.     delay(DELAY*fun); floodfill(x0 + R/3 + 1, y0,color);        // to mau canh phai
  27.     delay(DELAY*fun); floodfill(x0 - R/3 - 1, y0 + R/3,color);// to mau canh trai duoi 
  28.     delay(DELAY*fun); floodfill(x0 + R/3 - 1, y0 + R/3 + 1,color);  // to mau canh phai duoi
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement