RosettaCodeData/Task/Yin-and-yang/Delphi/yin-and-yang.delphi
Ingy döt Net 776bba907c Sync
2013-10-27 22:24:23 +00:00

51 lines
1.6 KiB
Text

procedure DrawYinAndYang(Canv: TCanvas; R: TRect);
begin
Canv.Brush.Color := clWhite;
Canv.Pen.Color := clWhite;
Canv.Pie(R.Left, R.Top, R.Right, R.Bottom,
(R.Right + R.Left) div 2, R.Top, (R.Right + R.Left) div 2, R.Bottom);
Canv.Brush.Color := clBlack;
Canv.Pen.Color := clBlack;
Canv.Pie(R.Left, R.Top, R.Right, R.Bottom,
(R.Right + R.Left) div 2, R.Bottom, (R.Right + R.Left) div 2, R.Top);
Canv.Brush.Color := clWhite;
Canv.Pen.Color := clWhite;
Canv.Ellipse((R.Right + 3 * R.Left) div 4, R.Top,
(3 * R.Right + R.Left) div 4, (R.Top + R.Bottom) div 2);
Canv.Brush.Color := clBlack;
Canv.Pen.Color := clBlack;
Canv.Ellipse((R.Right + 3 * R.Left) div 4, (R.Top + R.Bottom) div 2,
(3 * R.Right + R.Left) div 4, R.Bottom);
Canv.Brush.Color := clWhite;
Canv.Pen.Color := clWhite;
Canv.Ellipse((7 * R.Right + 9 * R.Left) div 16, (11 * R.Bottom + 5 * R.Top) div 16,
(9 * R.Right + 7 * R.Left) div 16, (13 * R.Bottom + 3 * R.Top) div 16);
Canv.Brush.Color := clBlack;
Canv.Pen.Color := clBlack;
Canv.Ellipse((7 * R.Right + 9 * R.Left) div 16, (3 * R.Bottom + 13 * R.Top) div 16,
(9 * R.Right + 7 * R.Left) div 16, (5 * R.Bottom + 11 * R.Top) div 16);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ClientWidth := 400;
ClientHeight := 400;
end;
procedure TForm1.FormPaint(Sender: TObject);
var
R: TRect;
begin
R := ClientRect;
Canvas.Brush.Color := clGray;
Canvas.FillRect(R);
InflateRect(R, -50, -50);
OffsetRect(R, -40, -40);
DrawYinAndYang(Canvas, R);
InflateRect(R, -90, -90);
OffsetRect(R, 170, 170);
DrawYinAndYang(Canvas, R);
end;