{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
import IHaskell.Display.Diagrams
import Diagrams.Backend.Cairo
import Diagrams.Prelude
hilbert 0 = mempty
hilbert n = hilbert' (n-1) # reflectY <> vrule 1
<> hilbert (n-1) <> hrule 1
<> hilbert (n-1) <> vrule (-1)
<> hilbert' (n-1) # reflectX
where
hilbert' m = hilbert m # rotateBy (1/4)
diagram :: Diagram B
diagram = strokeT (hilbert 6) # lc silver ||| ( strokeT (hilbert 5) # lc blue
=== strokeT (hilbert 5) # lc red )
diagram
rotateBy (1/4) diagram -- This was previously shown with a different size, because
-- it has different aspect ratio. If we fix the diagonal
-- by default instead of the height, this is not an issue.
withImgHeight 200 diagram
withImgWidth 200 diagram
anim :: Animation B V2 Double
anim = ui <&> \t -> center . rotateBy (t/4) $ (circle 1 ||| circle 1) === (circle 1 ||| circle 1)
anim
withImgHeight 50 anim