user
The discovery of the Harriss Spiral was first publicized about 2015. It is the brainchild of Edmund Orme Harriss, a British mathematician, writer and artist. Since 2010 he has been at the Fulbright College of Arts & Sciences at The University of Arkansas in Fayetteville, Arkansas, where he is an Assistant Professor of Arts & Sciences (ARSC) and Mathematical Sciences (MASC). He does research in the Geometry of Tilings and Patterns,a branch of Convex and Discrete Geometry.

In Harriss' own words, his namesake spiral, "…is constructed by taking a rectangle with height 1 and length the real root of x^3-x-1=0. With this rectangle you can cut off a similar rectangle, and then a square to get another similar rectangle. You can repeat this construction on the smaller similar rectangles, in each case getting a square and two more similar rectangles. Now simply adding an arc of a circle to each square (in the right way) gives the spiral, or more correctly the nest of spirals."

Fractal spiral discovered by Edmund Harriss

The Harriss Spiral is a variant of the decomposition for the golden spiral in which a rectangle is decomposed into three smaller units: a rectangle similar to the original rotated 90◦, a square, and a similar rectangle in the same orientation as the original rectangle. As in the golden-spiral decomposition, the individual non-square units can be decomposed further along these lines to create a cascading filling of the rectangle with ever-smaller squares. Unlike in the golden spiral, each square is incident on two smaller regions appearing in the same generation; if arcs are drawn between each square and the square which appeared in its previous generation The result is a branching structure, shown at right.

As with the golden spiral decomposition, the Harriss spiral requires a specific aspect ratio for the original rectangle. While the golden spiral requires an aspect ratio which is a solution to 𝜙2 = 𝜙 + 1 — the Golden Ratio of 1:1.618 — the Harriss spiral requires an aspect ratio 𝜌 satisfying 𝜌3 = 𝜌 + 1, whose real solution is known as the plastic ratio and equals 1:1.3247.

Task

Create and display a Harriss Spiral in your language.
assistant
**Translation of**: Julia

```
# 20250129 Raku programming solution

use Cairo;

constant HR = 1.324718;  # The Harriss Ratio, aka Ian Stewart's "plastic number"

sub harriss($ctx, $x, $y, $angle, $len, $iteration, $linew, $radius is copy = 0.0, $cntrx is copy = 0.0, $cntry is copy = 0.0) {
   return if $iteration < 1;

   my $startangle = $angle + 45;
   my $endangle = $startangle + 90;

   # Calculate end point of lines
   my $xend = $x + $len * cos($angle * pi / 180);
   my $yend = $y + $len * sin($angle * pi / 180);

   $radius = $len / sqrt(2);
   my $heading = $yend < $y ?? "SN" !! $xend < $x ?? "EW" !! $yend > $y ?? "NS" !! $xend > $x ?? "WE" !! "DIE";

   given $heading {
      when "SN" { $cntrx = $x - $len / 2;
                  $cntry = $y - $len / 2;
                  $ctx.rgb(1, 1, 0);      }
      when "EW" { $cntrx = $x - $len / 2;
                  $cntry = $y + $len / 2;
                  $ctx.rgb(1, 0, 0);      }
      when "NS" { $cntrx = $x + $len / 2;
                  $cntry = $y + $len / 2;
                  $ctx.rgb(0, 0, 1);      }
      when "WE" { $cntrx = $x + $len / 2;
                  $cntry = $y - $len / 2;
                  $ctx.rgb(0, 0, 0);      }
      default   { die }
   }

   $ctx.line_width = $linew;
   $ctx.arc($cntrx, $cntry, $radius, $startangle * pi / 180, $endangle * pi / 180);
   $ctx.stroke;

   harriss($ctx, $xend, $yend, $angle - 90, $len / HR, $iteration - 1, $linew, $radius, $cntrx, $cntry);
}

given Cairo::Image.create(Cairo::FORMAT_ARGB32, 1400, 1000) {  
   given Cairo::Context.new($_) {
      .rgb(0.827, 0.827, 0.827);  # light gray background
      .paint;
      .rgb(0, 0, 0);  
      .line_width = 1.0;

      my ($startx, $starty, $init_len) = 750, 740, 525 / HR / HR;

      # Reverse Order Hides Joints
      harriss($_, $startx - ($init_len / HR + $init_len / HR**3), $starty - $init_len / HR**7, 180, $init_len / HR**6, 2, 6.0);
      harriss($_, $startx - ($init_len / HR + $init_len / HR**3), $starty - ($init_len + $init_len / HR**2), 270, $init_len / HR**5, 3, 6.0);
      harriss($_, $startx + $init_len / HR**4, $starty - ($init_len + $init_len / HR**2), 270, $init_len / HR**5, 3, 6.0);
      harriss($_, $startx + $init_len / HR, $starty - ($init_len + $init_len / HR**2), 0, $init_len / HR**4, 4, 6.0);
      harriss($_, $startx - $init_len / HR**4, $starty - $init_len / HR, 0, $init_len / HR**5, 2, 10.0);
      harriss($_, $startx - $init_len / HR**4, $starty - $init_len / HR**3, -270, $init_len / HR**4, 3, 12.0);
      harriss($_, $startx - $init_len / HR, $starty - $init_len / HR**3, 180, $init_len / HR**3, 4, 12.0);
      harriss($_, $startx - $init_len / HR, $starty - $init_len, 270, $init_len / HR**2, 5, 14.0);
      harriss($_, $startx, $starty - $init_len, 0, $init_len / HR, 6, 14.0);
      harriss($_, $startx, $starty, -90, $init_len, 7, 18.0);
   }
   .write_png("harriss-spirals-raku.png");
}

```