Spiral: Proper Fills and Add Arcs on each end lazarus / 39-Graphics ---------------------------------------------------------------------- Boleeman · 2024-04-09 09:22 Been working on filling some spirals with colors and making their ends round with arcs (as shown in the attached picture) Can't seem to get the fill to work just between the red lines with random colors. Always have  a bigger snail like shape filled on top that obscures the other spiral sections. The CSharp Helper site has something similar , but I could not work out how Mr Stevens did it. His spiral ends all line up. My spiral ends are radially spaced. Attached is his csharp version picture. Also, as the form is resized the number of spirals increase dynamically. Here is my code so far: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,  Spin; type   { TForm1 }   TForm1 = class(TForm)    chkDirection: TCheckBox;    PaintBox1: TPaintBox;    Panel1: TPanel;    seAValue: TSpinEdit;    seNumSpirals: TSpinEdit;    procedure chkDirectionChange(Sender: TObject);    procedure PaintBox1Paint(Sender: TObject);    procedure seAValueChange(Sender: TObject);    procedure seNumSpiralsChange(Sender: TObject);  private    SpiralBrushes: array of TBrush;    function Distance(point1, point2: TPoint): Single;    procedure DrawSpirals(ACanvas: TCanvas; center: TPoint; A: Single; num_spirals: Integer; rect: TRect);    procedure PolarToCartesian(r, theta: Single; out x, y: Single);  public   end; var  Form1: TForm1; implementation {$R *.lfm}  procedure TForm1.PaintBox1Paint(Sender: TObject);begin  DrawSpirals(PaintBox1.Canvas, Point(PaintBox1.Width div 2, PaintBox1.Height div 2), seAValue.Value, seNumSpirals.Value, PaintBox1.ClientRect);end; procedure TForm1.chkDirectionChange(Sender: TObject);begin      PaintBox1.Invalidate;end; procedure TForm1.seAValueChange(Sender: TObject);begin    PaintBox1.Invalidate;end; procedure TForm1.seNumSpiralsChange(Sender: TObject);begin    PaintBox1.Invalidate;end; procedure TForm1.DrawSpirals(ACanvas: TCanvas; center: TPoint; A: Single; num_spirals: Integer; rect: TRect);var  i: Integer;  d_start, start_angle, max_dist, max_theta, theta, r, x, y: Single;  points: array of TPoint;  rectCenter: TPoint;begin  ACanvas.Clear;  ACanvas.Pen.Color := clBlack;  ACanvas.Brush.Style := bsClear;   d_start := 2 * Pi / num_spirals;  start_angle := 0;  max_theta := max_dist / A + 2 * Pi;   SetLength(points, 0);  for i := 1 to num_spirals do  begin    theta := 0;    SetLength(points, 0);    while theta <= max_theta do    begin      r := A * theta;      PolarToCartesian(r, theta + start_angle, x, y);      x += center.X;    y := center.Y + y;      SetLength(points, Length(points) + 1);      points[High(points)] := Point(Trunc(x), Trunc(y));      theta += Pi / 36; // 5 degrees    end;    ACanvas.Pen.Color := clRed; // Set pen color to red for curved spiral lines    ACanvas.Polyline(points); // Draw radial lines    start_angle += d_start;     ACanvas.Pen.Color := clBlue; // Set pen color to blue    ACanvas.MoveTo(Round(center.X + (points[High(points)].X - center.X) * (num_spirals - 1) / num_spirals), Round(center.Y + (points[High(points)].Y - center.Y) * (num_spirals - 1) / num_spirals)); // Move pen to three-quarters of the distance from the center to the end of the radial line    ACanvas.LineTo(points[High(points)].X, points[High(points)].Y); // Draw line to end of the radial line  end;end; function TForm1.Distance(point1, point2: TPoint): Single;var  dx, dy: Single;begin  dx := point1.X - point2.X;  dy := point1.Y - point2.Y;  Result := Sqrt(dx * dx + dy * dy);end; procedure TForm1.PolarToCartesian(r, theta: Single; out x, y: Single);begin  x := r * Cos(theta);  y := r * Sin(theta);end; end.  end.