implementation
uses
Math;
{$R *.dfm}
procedure
TForm1
.
PaintBox1Paint(Sender: TObject);
var
x0, y0, I, N:
Integer
;
Angle, R, s, c:
Extended
;
begin
x0:= PaintBox1
.
Width
div
2
;
y0:= PaintBox1
.
Height
div
2
;
PaintBox1
.
Canvas
.
MoveTo(x0, y0);
N:=
100
;
for
I:=
0
to
N
do
begin
Angle:= ((Pi/
3
)*I)/N;
SinCos(Angle, s, c);
R:= Sin(
3
*Angle)*Min(x0, y0);
PaintBox1
.
Canvas
.
LineTo(x0+Round(R*c), y0+Round(R*s));
end
;
for
I:=
0
to
N
do
begin
Angle:= ((Pi/
3
)*I)/N +
2
*Pi/
3
;
SinCos(Angle, s, c);
R:= Sin(
3
*Angle)*Min(x0, y0);
PaintBox1
.
Canvas
.
LineTo(x0+Round(R*c), y0+Round(R*s));
end
;
for
I:=
0
to
N
do
begin
Angle:= ((Pi/
3
)*I)/N -
2
*Pi/
3
;
SinCos(Angle, s, c);
R:= Sin(
3
*Angle)*Min(x0, y0);
PaintBox1
.
Canvas
.
LineTo(x0+Round(R*c), y0+Round(R*s));
end
;
end
;