Fractal construction with pentagons.
import Diagrams.Backend.SVG.CmdLine
{-# LANGUAGE NoMonomorphismRestriction #-}
import Diagrams.Prelude
A \(0\)-pentaflake is just a regular pentagon:
= defaultRG & _RG . rGradStops .~ mkStops [(blue,0,1), (crimson,1,1)]
grad & _RG . rGradRadius1 .~ 50
0 = regPoly 5 1 # lw none pentaflake'
An \(n\)-pentaflake
is an \((n-1)\)-pentaflake surrounded by five more. The appends
function is useful here for positioning the five pentaflakes around
the central one.
= appends
pentaflake' n
pCenterzip vs (repeat (rotateBy (1/2) pOutside)))
(where vs = iterateN 5 (rotateBy (1/5))
. (if odd n then negated else id)
$ unitY
= pentaflake' (n-1)
pCenter = pCenter # opacity (1.7 / fromIntegral n)
pOutside
= pentaflake' n # fillTexture grad # bgFrame 4 silver pentaflake n
A \(4\)-pentaflake looks nice. Of course there’s an exponential blowup in the number of primitives, so generating higher-order pentaflakes can take a long time!
= pentaflake 4 example
= mainWith (example :: Diagram B) main