diagrams-contrib-1.0: Collection of user contributions to diagrams EDSL

Maintainer byorgey@cis.upenn.edu None

Diagrams.TwoD.Path.IteratedSubset

Description

Generate fractal trails by the "iterated subset" construction, iteratively replacing each segment with a given pattern.

Synopsis

# Iterated subset algorithm

Given a "seed pattern", produce a list of successive refinements, where the nth trail in the list has iteratively had all segments replaced by the seed pattern n times, starting from a horizontal line. In other words, the zeroth trail in the output list is a horizontal unit segment, and each subsequent trail is equal to the previous with all segments replaced by the seed pattern.

``` import Diagrams.TwoD.Path.IteratedSubset
iterTrailEx = vcat' (with & sep .~ 0.3) . map strokeLine . take 5
\$ iterTrail koch
```

Use a trail to "refine" a segment, returning a scaled and/or rotated copy of the trail with the same endpoint as the segment.

# Examples

## Example seed trails

koch :: (TrailLike t, V t ~ R2) => tSource

Seed for the Koch curve (side of the famous Koch `snowflake`).

levy :: (TrailLike t, V t ~ R2) => tSource

Seed for the Lévy dragon curve.

zag :: (TrailLike t, V t ~ R2) => tSource

Strange zig-zag seed that produces a dense fractal path with lots of triangles.

sqUp :: (TrailLike t, V t ~ R2) => tSource

A "square impulse" seed which produces a quadratic von Koch curve.

sqUpDown :: (TrailLike t, V t ~ R2) => tSource

A "double square impulse" seed which produces fantastic rectilinear spiral patterns.

sqUpDown' :: (TrailLike t, V t ~ R2) => tSource

Like `sqUpDown` but with `cubicSpline` applied to produce a curvy version.

## Other stuff

A random collection of other fun things you can do with `iterTrail`. There is no particular emphasis on making these configurable or generic; the point is just to suggest some fun things you can do. If you want to play with them, copy the source code and modify it as you see fit.

The famous Koch snowflake, made by putting three Koch curves together. `snowflake n` yields an order-`n` snowflake.

A cool diagram featuring successive iterations of `sqUpDown'` superimposed atop one another.

Parameters to generate an iterated subset fractal.

Constructors

 ITC Fieldsseed :: Trail' Line R2The seed trail color :: Colour DoubleThe line color to use iters :: IntNumber of iterations

randITC :: (MonadRandom m, Applicative m) => m IterTrailConfigSource

Generate a random `IterTrailConfig`. This features many hard-coded values. If you want to play with it just copy the code and modify it to suit.

Generate an iterated subset fractal based on the given parameters.

drawITCScaled :: (Renderable (Path R2) b, Backend b R2) => IterTrailConfig -> Diagram b R2Source

Like `drawITC`, but also scales, centers, and pads the result so that it fits nicely inside a 4x4 box.

randIterGrid :: (Renderable (Path R2) b, Backend b R2) => IO (Diagram b R2)Source

Create a grid of 100 random iterated subset fractals. Impress your friends!