gruff 0.3 → 0.3.1
raw patch · 2 files changed
+36/−28 lines, 2 filesdep ~gruff
Dependency ranges changed: gruff
Files
- gruff.cabal +15/−8
- src/View.hs +21/−20
gruff.cabal view
@@ -1,16 +1,23 @@ Name: gruff-Version: 0.3+Version: 0.3.1 Synopsis: fractal explorer GUI using the ruff library Description: Mandelbrot Set fractal explorer using the ruff library. . Requires GTK, OpenGL, and GLSL fragment shader support; lots of RAM- and multiple CPU cores recommended. If you want to explore very deep- zooms, you'll need hmpfr which currently requires GHC to be compiled- with integer-simple instead of the default integer-gmp. To install- with MPFR support, use @cabal install gruff -fmpfr@. (Note that the- default setting for this flag has changed since the previous release.)+ and multiple CPU cores recommended. .+ If you want to explore very deep zooms, you'll need hmpfr which+ currently requires GHC to be compiled with integer-simple instead of+ the default integer-gmp. To install with MPFR support, use+ @cabal install gruff -fmpfr@.+ Note that the default setting for this flag has changed since gruff-0.2.+ .+ gruff-0.3.1 is a bugfix release, fixing a performance problem wherein+ offscreen tiles were needlessly calculated. The performance gain+ is much less (and in many cases is in fact a performance loss) when+ using integer-simple.+ . gruff-0.3 includes a small library to allow external programs to create diagrams and animations with gruff. See the gruff-examples package. The interface has been remodelled to simplify it and add@@ -102,7 +109,7 @@ Tile Utils View- Build-depends: gruff == 0.3,+ Build-depends: gruff == 0.3.1, base >= 4 && < 5, containers >= 0 && < 1, directory >= 1 && < 2,@@ -137,4 +144,4 @@ source-repository this type: git location: git://gitorious.org/ruff/gruff.git- tag: v0.3+ tag: v0.3.1
src/View.hs view
@@ -14,11 +14,12 @@ import Data.Bits (bit) import Data.Ratio ((%)) -import Fractal.RUFF.Types.Complex (Complex((:+)))+import Fractal.RUFF.Types.Complex (Complex((:+)), magnitude) import Fractal.GRUFF -import QuadTree (Quad(..), Child(..), child)+import QuadTree (Quad(..), Child(..), child, Square(..), square)+import Tile (rootSquare) pixelLocation :: Window -> Viewport -> Location -> Double -> Double -> Complex Rational pixelLocation w v l = let f = fromScreenCoords w v l in \x y -> f (x :+ y)@@ -118,25 +119,25 @@ visibleQuads :: Window -> Viewport -> Location -> Int -> Maybe ([(Complex Int, Quad)], [(Complex Int, Quad)]) visibleQuads w v l o = do let b = bufferSize o w- a = orient v- co = cos a- si = sin a- k = 0.5 ** (delta l - fromIntegral o)- x1 = k * fromIntegral (width w)- y1 = k * fromIntegral (height w)- x0 = - x1- y0 = - y1- visible t (i :+ j, _) =- let d = if t then texels b else texels b `div` 2- in not . and $- [ x < x0 || y < y0 || x1 < x || y1 < y- | di <- [0, 1], let i' = fromIntegral (i - d + di * tileSize)- , dj <- [0, 1], let j' = fromIntegral (j - d + dj * tileSize)- , let x = co * i' + si * j', let y = -si * i' + co * j'- ]+ x0 = 0+ y0 = 0+ x1 = fromIntegral (width w)+ y1 = fromIntegral (height w)+ toScreen = toScreenCoords w v l+ visible (_, q) =+ let s = square rootSquare q+ d = squareSize s / 2+ r = magnitude $ p - p0+ c0 = squareWest s :+ squareNorth s+ c = (squareWest s + d) :+ (squareNorth s + d)+ p0 = toScreen c0+ p@(x :+ y) = toScreen c+ in not $ x < x0 - r || y < y0 - r || x1 + r < x || y1 + r < y qs0 <- bufferQuads l b- let qs1 = concatMap childQuads qs0- return ( filter (visible False) qs0 , filter (visible True) qs1 )+ let qs0' = filter visible qs0+ qs1 = concatMap childQuads qs0'+ qs1' = filter visible qs1+ return (qs0', qs1') defImage :: Image defImage = Image