Cờ Việt Nam

M

mikelhpdatke

Chú ý sửa đường dẫn trong phần main nha :D

Mã:
uses graph;
type point = record
  x, y: integer;
 end;

procedure drawStar(x, y, r, color: integer);
var rad, i: integer;
 p: array [1..5] of point;
begin
 {border}
 setcolor(color);
 rad := 0;
 for i := 1 to 5 do begin
  p[i].x := trunc(x + r * sin(PI / 180 * rad));
  p[i].y := trunc(y - r * cos(PI / 180 * rad));
  inc(rad, 72);
 end;
 moveto(p[1].x, p[1].y);
 lineto(p[4].x, p[4].y);
 lineto(p[2].x, p[2].y);
 lineto(p[5].x, p[5].y);
 lineto(p[3].x, p[3].y);
 lineto(p[1].x, p[1].y);
 {fill}
 setfillstyle(1, color);
 floodfill(x, y, color);
 floodfill(p[1].x, p[1].y + 3, color);
 floodfill(p[2].x - 3, p[2].y + 1, color);
 floodfill(p[3].x - 3, p[3].y - 3, color);
 floodfill(p[4].x + 3, p[4].y - 3, color);
 floodfill(p[5].x + 3, p[5].y + 1, color);
end;

procedure drawFlag(x, y, w, h: integer);
var r: integer;
begin
 setcolor(red);
 rectangle(x, y, x + w, y + h);
 setfillstyle(1, red);
 floodfill(x + 1, y + 1, red);
 if w > h then r := h div 4
 else r := w div 4;
 drawStar(w div 2 + x, h div 2 + y, r, yellow);
end;

VAR gd, gm: integer;
BEGIN
 gd:=detect;
 initgraph(gd,gm,'E:\tp\bgi');
 drawFlag(100,50,400,300);
 readln;
 closegraph;
END.
 
Top Bottom