peteg's blog - hacking - 2008 08 15 FishLimit

Another old friend.

/hacking | Link

Here is a friend of the fish cycle: the "fish limit".

Argh, your browser does not support SVG!

Again, if you look at the free standing SVG file, you should be able to exercise the scaling feature of your SVG implementation.

Although the SVG rendering consists of only a finite set of lines, the original FLAN source code describes an infinite set; the interpreter decides to stop generating that set once the lines get too small.

polyline :: [(Num, Num)] -> [Shape]
polyline pts =
  match pts with
      []   -> []
    | p:ps ->
        let mkP :: (Num, Num) -> [(Num, Num)] -> [Shape]
            mkP prev qqs =
              match qqs with
                  []   -> [] -- Don't close the polygon.
                | q:qs -> (Line prev q) : (mkP q qs)
              end ;
         in mkP p ps
  end
;

leftFish :: Picture
leftFish =
    Canvas 1 1
      ((Line (1/8, 3/5) (1, 4/5))
       : (polyline [ (1, 1), (1/8, 3/5), (1, 1/8), (3/4, 0), (1, 0)]))
;

rightFish :: Picture
rightFish = Flip leftFish
;

fish :: Picture
fish = Beside 1 1 leftFish rightFish
;
sideFish :: Picture
sideFish = Rotate fish
;

foodChain :: Picture
foodChain =
  let p :: Picture
      p = Beside 1 1 foodChain sideFish ;
  in Above 1 1 p p
;

main = foodChain