gruff-examples 0.3.1 → 0.4
raw patch · 5 files changed
+132/−33 lines, 5 filesdep ~Vecdep ~gruffdep ~ruffnew-component:exe:gruff-fivesnew-component:exe:gruff-zoom
Dependency ranges changed: Vec, gruff, ruff
Files
- gruff-examples.cabal +45/−27
- src/gruff-fives.hs +61/−0
- src/gruff-labels.hs +3/−1
- src/gruff-randoms.hs +5/−5
- src/gruff-zoom.hs +18/−0
gruff-examples.cabal view
@@ -1,5 +1,5 @@ Name: gruff-examples-Version: 0.3.1+Version: 0.4 Synopsis: Mandelbrot Set examples using ruff and gruff Description: Some example scripts, including a converter from old versions of gruff@@ -8,7 +8,7 @@ License: GPL-2 License-file: LICENSE Author: Claude Heiland-Allen-Maintainer: claudiusmaximus@goto10.org+Maintainer: claude@mathr.co.uk Category: Graphics Build-type: Simple@@ -28,96 +28,114 @@ Convert.Gruff2 Build-depends: base >= 4 && < 5, filepath,- ruff >= 0.3 && < 0.4,- gruff >= 0.3 && < 0.4+ ruff >= 0.4 && < 0.5,+ gruff >= 0.4 && < 0.5 GHC-options: -Wall -threaded -rtsopts- GHC-Prof-Options: -prof -auto-all -caf-all Executable gruff-labels Hs-source-dirs: src Main-is: gruff-labels.hs Build-depends: base >= 4 && < 5, containers,- gruff >= 0.3 && < 0.4,- ruff >= 0.3 && < 0.4+ gruff >= 0.4 && < 0.5,+ ruff >= 0.4 && < 0.5 GHC-options: -Wall -threaded -rtsopts- GHC-Prof-Options: -prof -auto-all -caf-all Executable gruff-octopus Hs-source-dirs: src Main-is: gruff-octopus.hs Other-modules: Number Build-depends: base >= 4 && < 5,- gruff >= 0.3 && < 0.4,- ruff >= 0.3 && < 0.4,+ gruff >= 0.4 && < 0.5,+ ruff >= 0.4 && < 0.5, qd >= 1 && < 2, qd-vec >= 1 && < 2,- Vec >= 0.9 && < 1.0+ Vec >= 1 && < 2 if (flag(mpfr)) Build-depends: hmpfr >= 0.3.2 && < 0.4 CPP-options: -DHAVE_MPFR CC-options: -DHAVE_MPFR GHC-options: -Wall -threaded -rtsopts- GHC-Prof-Options: -prof -auto-all -caf-all +Executable gruff-fives+ Hs-source-dirs: src+ Main-is: gruff-fives.hs+ Other-modules: Number+ Build-depends: base >= 4 && < 5,+ gruff >= 0.4 && < 0.5,+ ruff >= 0.4 && < 0.5,+ qd >= 1 && < 2,+ qd-vec >= 1 && < 2,+ Vec >= 1 && < 2+ if (flag(mpfr))+ Build-depends: hmpfr >= 0.3.2 && < 0.4+ CPP-options: -DHAVE_MPFR+ CC-options: -DHAVE_MPFR+ GHC-options: -Wall -threaded -rtsopts+ Executable gruff-patterns Hs-source-dirs: src Main-is: gruff-patterns.hs Other-modules: Number Build-depends: base >= 4 && < 5,- gruff >= 0.3 && < 0.4,- ruff >= 0.3 && < 0.4,+ gruff >= 0.4 && < 0.5,+ ruff >= 0.4 && < 0.5, qd >= 1 && < 2, qd-vec >= 1 && < 2,- Vec >= 0.9 && < 1.0+ Vec >= 1 && < 2 if (flag(mpfr)) Build-depends: hmpfr >= 0.3.2 && < 0.4 CPP-options: -DHAVE_MPFR CC-options: -DHAVE_MPFR GHC-options: -Wall -threaded -rtsopts- GHC-Prof-Options: -prof -auto-all -caf-all Executable gruff-randoms Hs-source-dirs: src Main-is: gruff-randoms.hs Other-modules: Number Build-depends: base >= 4 && < 5,- gruff >= 0.3 && < 0.4,- ruff >= 0.3 && < 0.4,+ gruff >= 0.4 && < 0.5,+ ruff >= 0.4 && < 0.5, qd >= 1 && < 2, qd-vec >= 1 && < 2,- Vec >= 0.9 && < 1.0,+ Vec >= 1 && < 2, random >= 1.0 && < 1.1 if (flag(mpfr)) Build-depends: hmpfr >= 0.3.2 && < 0.4 CPP-options: -DHAVE_MPFR CC-options: -DHAVE_MPFR GHC-options: -Wall -threaded -rtsopts- GHC-Prof-Options: -prof -auto-all -caf-all Executable gruff-whn Hs-source-dirs: src Main-is: gruff-whn.hs Other-modules: Number Build-depends: base >= 4 && < 5,- gruff >= 0.3 && < 0.4,- ruff >= 0.3 && < 0.4,+ gruff >= 0.4 && < 0.5,+ ruff >= 0.4 && < 0.5, qd >= 1 && < 2, qd-vec >= 1 && < 2,- Vec >= 0.9 && < 1.0,+ Vec >= 1 && < 2, data-memocombinators >= 0.4 && < 0.5 if (flag(mpfr)) Build-depends: hmpfr >= 0.3.2 && < 0.4 CPP-options: -DHAVE_MPFR CC-options: -DHAVE_MPFR GHC-options: -Wall -threaded -rtsopts- GHC-Prof-Options: -prof -auto-all -caf-all +Executable gruff-zoom+ Hs-source-dirs: src+ Main-is: gruff-zoom.hs+ Build-depends: base >= 4 && < 5,+ gruff >= 0.4 && < 0.5+ GHC-options: -Wall -threaded -rtsopts++ source-repository head type: git- location: git://gitorious.org/ruff/gruff-examples.git+ location: http://code.mathr.co.uk/gruff-examples.git source-repository this type: git- location: git://gitorious.org/ruff/gruff-examples.git- tag: v0.3.1+ location: http://code.mathr.co.uk/gruff-examples.git+ tag: v0.4
+ src/gruff-fives.hs view
@@ -0,0 +1,61 @@+import Data.Maybe (mapMaybe)++import Fractal.GRUFF++import Fractal.RUFF.Mandelbrot.Address (parseAngledInternalAddress)+import Fractal.RUFF.Mandelbrot.Atom (MuAtom(..), findAtom_)+import Fractal.RUFF.Types.Complex (Complex((:+)))++import Number (R)++main :: IO ()+main = defaultMain animation++animation :: [(Image, FilePath)]+animation = mapMaybe scene score++scene :: String -> Maybe (Image, FilePath)+scene s = do+ m <- findAtom_ =<< parseAngledInternalAddress s+ let cx :+ cy = muNucleus m :: Complex R+ f = filename s+ i = Image+ { imageLocation = Location+ { center = toRational cx :+ toRational cy+ , radius = muSize m * 16+ }+ , imageViewport = Viewport+ { aspect = 1+ , orient = muOrient m - pi / 2+ }+ , imageWindow = Window+ { width = 512+ , height = 288+ , supersamples = 8+ }+ , imageColours = Colours+ { colourInterior = Colour 1 0.75 0+ , colourBoundary = Colour 0 0 0+ , colourExterior = Colour 1 1 1+ }+ , imageLabels = []+ , imageLines = []+ }+ return (i, f)++filename :: String -> FilePath+filename s = map filechar s ++ ".ppm"+ where+ filechar ' ' = '_'+ filechar '/' = '-'+ filechar c = c++score :: [String]+score =+ [ "1 1/5 5 6 " ++ accum deltas+ | l <- [0 .. 124]+ , let m = l `div` 5+ , let n = l `mod` 5 + 1+ , let deltas = replicate m 5 ++ [n]+ ]+ where accum = unwords . map show . scanl (+) 11
src/gruff-labels.hs view
@@ -1,9 +1,10 @@ import Fractal.GRUFF -import Fractal.RUFF.Mandelbrot.Address+import Fractal.RUFF.Mandelbrot.Address hiding (angles) import Fractal.RUFF.Mandelbrot.Ray import Fractal.RUFF.Mandelbrot.Atom import Fractal.RUFF.Types.Complex+import Fractal.RUFF.Types.Ratio hiding (Rational) import Control.Monad (ap, replicateM) import qualified Data.Map as M@@ -80,6 +81,7 @@ . map toRationalC . take (sharpness * 32) . externalRay 1e-8 sharpness (2**24)+ . (\t -> toRational (numerator t) / toRational (denominator t)) sharpness :: Int sharpness = 8
src/gruff-randoms.hs view
@@ -3,7 +3,6 @@ import Control.Monad (forM_) import Data.Function (on) import Data.List (nub, nubBy, unfoldr)-import Data.Ratio (denominator, (%)) import System.Environment (getArgs) import System.Random (newStdGen, RandomGen, random, randomR, split) @@ -15,6 +14,7 @@ ) import Fractal.RUFF.Mandelbrot.Atom (MuAtom(..), findAtom_) import Fractal.RUFF.Types.Complex (Complex((:+)))+import Fractal.RUFF.Types.Ratio (denominator, (%)) import Number (R) @@ -95,13 +95,13 @@ randomAddress' :: RandomGen g => g -> Int -> Integer -> Integer -> (g, AngledInternalAddress)-randomAddress' g0 size _den per | size == 0 || per > 100 = (g0, Unangled per)+randomAddress' g0 size _den per | size == 0 || per > 100 = (g0, Unangled (fromInteger per)) randomAddress' g0 size den per | coin < (0.125 :: Double) && den' > 2 = if per' > 200- then (g6, Unangled per)- else Angled per angle `fmap` randomAddress' g6 (size - 1) den' per'- | otherwise = Angled per (1/2) `fmap` randomAddress' g6 (size - 1) den per2+ then (g6, Unangled (fromInteger per))+ else Angled (fromInteger per) angle `fmap` randomAddress' g6 (size - 1) den' per'+ | otherwise = Angled (fromInteger per) (1 % 2) `fmap` randomAddress' g6 (size - 1) den per2 where (coin, g1) = random g0 (rand, g2) = random g1
+ src/gruff-zoom.hs view
@@ -0,0 +1,18 @@+import System.Environment (getArgs)++import Fractal.GRUFF++main :: IO ()+main = do+ [fn, nfs] <- getArgs+ i0 <- read `fmap` readFile fn+ let nf = read nfs+ r0 = 4+ r1 = radius (imageLocation i0)+ dr = r1 / r0+ zoom f =+ let t = fromIntegral f / fromIntegral (nf - 1)+ r = r0 * dr ** t+ in i0{ imageLocation = (imageLocation i0){ radius = r } }+ name = (++ ".ppm") . reverse . take 8 . (++ "00000000") . reverse . show+ defaultMain [ (zoom f, name f) | f <- [0 .. nf - 1] ]