procedure TForm1.Timer1Timer(Sender: TObject);
var
x, y, _x, _y, b,temp1,angle: Single;
j: Integer;
cx, cy: Integer;
col: TBGRAPixel;
pathPoints: array of TPoint;
numVertices, PhaseDivisor, theSpeed: Integer;
_t: Single;
hueDot, hueLine: Single;
invNumVert: Single;
sinT, cosT: Single;
invPhase: Single;
begin
bmp.Fill(BGRA(12, 12, 12, seFillAlpha.Value));
cx := bmp.Width div 2;
cy := bmp.Height div 2;
theSpeed := tbSpeed.Position;
numVertices := seVertices.Value;
// CoEffofT := seCoEffofT.Value;
PhaseDivisor := sePhaseDivisor.Value;
_t := 1 / theSpeed;
SetLength(pathPoints, num);
// Precompute smooth hue values
hueDot := Frac(u / 360); // Dots hue
hueLine := Frac((u + 30) / 360); // Offset for line hue
// constants used loop
col := myHSLAtoBGRAFast(hueDot, 0.9, 0.7, 0.3);
temp1:=0.55 * Sin(5);
invNumVert := 1 / (numVertices - 2);
invPhase := Pi / PhaseDivisor;
sinT := Sin(t);
cosT := Cos(t);
for j := 0 to num - 1 do
begin
x := j * temp1;
angle := 3 * t + x * 0.5 + invPhase;
y := x * Sin(angle) * invNumVert;
b := (j * (numVertices - 1)) * Pi / numVertices;
_x := x * Cos(b) + y * sinT;
_y := x * Sin(b) + y * cosT;
pathPoints[j] := Point(Round(cx + _x), Round(cy + _y));
bmp.FillEllipseAntialias(pathPoints[j].X, pathPoints[j].Y, 2, 2, col);
end;
// Draw path
col := myHSLAtoBGRAFast(hueLine, 0.6, 0.3, 0.1);
bmp.DrawPolyLineAntialias(pathPoints, col, False);
// Animate parameters
t += _t;
u -= 0.5;
if u < 0 then u := u + 360;
bmp.Draw(PaintBox1.Canvas, 0, 0, True);
end;