IFS-0.1: src/Graphics/IFS/Examples.hs
---------------------------------------------------------------------------
-- |
-- Module : Main
-- Copyright : (c) alpheccar, 2007
-- License : BSD-style
--
-- Maintainer : misc@alpheccar.org
-- Stability : experimental
-- Portability : non-portable (multi-parameter type classes)
--
-- Description
--
-- Example IFS
--
-----------------------------------------------------------------------------
module Graphics.IFS.Examples(
-- * Example IFS
sierpinski
, square
, fern
-- * Example of use
-- $Example
)
where
import Graphics.IFS.Geometry
import Graphics.IFS
sierpinski :: IFS Double
sierpinski = 0.33 <?> linearIFS (scaling 0.5 0.5)
<+> 0.33 <?> linearIFS (translation 0.5 0 * scaling 0.5 0.5)
<+> 0.33 <?> linearIFS (translation 0 0.5 * scaling 0.5 0.5)
square :: IFS Double
square = 0.25 <?> linearIFS (scaling 0.5 0.5)
<+> 0.25 <?> linearIFS (translation 0.5 0 * scaling 0.5 0.5)
<+> 0.25 <?> linearIFS (translation 0 0.5 * scaling 0.5 0.5)
<+> 0.25 <?> linearIFS (translation 0.5 0.5 * scaling 0.5 0.5)
fern :: IFS Double
fern = (0.01 <?> linearIFS(linear 0 0 0 0.16 0 0)
<+> 0.08 <?> linearIFS(linear 0.2 (-0.26) 0.23 0.22 0 1.6)
<+> 0.08 <?> linearIFS(linear (-0.15) 0.28 0.26 0.24 0 0.44)
<+> 0.74 <?> linearIFS(linear 0.75 0.04 (-0.04) 0.85 0 1.6))
{- $Example
[Generating the fractal for the Sierpinski IFS:]
> createPict "essai.ppm" 600 600 1.0 200000 (binaryColor white blue) sierpinski
[Combining square and sierpinski:]
> createPict "essai.ppm" 600 600 1.0 200000 (binaryColor white blue) (0.5 <?> square <+> 0.5 <?> sierpinski)
[Definitions of the examples:]
> sierpinski :: IFS Double
> sierpinski = 0.33 <?> linearIFS (scaling 0.5 0.5)
> <+> 0.33 <?> linearIFS (translation 0.5 0 * scaling 0.5 0.5)
> <+> 0.33 <?> linearIFS (translation 0 0.5 * scaling 0.5 0.5)
>
> square :: IFS Double
> square = 0.25 <?> linearIFS (scaling 0.5 0.5)
> <+> 0.25 <?> linearIFS (translation 0.5 0 * scaling 0.5 0.5)
> <+> 0.25 <?> linearIFS (translation 0 0.5 * scaling 0.5 0.5)
> <+> 0.25 <?> linearIFS (translation 0.5 0.5 * scaling 0.5 0.5)
-}