From 11f3685b549921fd8b772511d58dc00bb3d1cbfd Mon Sep 17 00:00:00 2001 From: Yann Esposito Date: Mon, 11 Jun 2012 16:53:26 +0200 Subject: [PATCH] hlinted --- 06_Mandelbulb/ExtComplex.hs | 6 +++--- 06_Mandelbulb/Mandel.hs | 2 +- 06_Mandelbulb/Mandelbulb.lhs | 7 ++++--- 06_Mandelbulb/YGL.hs | 23 +++++++++-------------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/06_Mandelbulb/ExtComplex.hs b/06_Mandelbulb/ExtComplex.hs index 6500028..66861b9 100644 --- a/06_Mandelbulb/ExtComplex.hs +++ b/06_Mandelbulb/ExtComplex.hs @@ -21,13 +21,13 @@ extcomplex :: GLfloat -> GLfloat -> GLfloat -> ExtComplex extcomplex x y z = C (x,y,z) real :: ExtComplex -> GLfloat -real (C (x,y,z)) = x +real (C (x,_,_)) = x im :: ExtComplex -> GLfloat -im (C (x,y,z)) = y +im (C (_,y,_)) = y strange :: ExtComplex -> GLfloat -strange (C (x,y,z)) = z +strange (C (_,_,z)) = z magnitude :: ExtComplex -> GLfloat magnitude = real.abs diff --git a/06_Mandelbulb/Mandel.hs b/06_Mandelbulb/Mandel.hs index 9500e0b..3997a83 100644 --- a/06_Mandelbulb/Mandel.hs +++ b/06_Mandelbulb/Mandel.hs @@ -7,7 +7,7 @@ mandel r i s nbIterations = f (extcomplex r i s) 0 nbIterations where f :: ExtComplex -> ExtComplex -> Int -> Int - f c z 0 = 0 + f _ _ 0 = 0 f c z n = if (magnitude z > 2 ) then n else f c ((z*z)+c) (n-1) diff --git a/06_Mandelbulb/Mandelbulb.lhs b/06_Mandelbulb/Mandelbulb.lhs index 556f0e0..bfad62d 100644 --- a/06_Mandelbulb/Mandelbulb.lhs +++ b/06_Mandelbulb/Mandelbulb.lhs @@ -3,7 +3,7 @@ All feel good from the architecture point of vue. More precisely, the separation between rendering and world behavior is clear. But this is extremely slow now. -Because we compute the mandelbulb for each frame now. +Because we compute the Mandelbulb for each frame now. Before we had @@ -120,7 +120,7 @@ Our initial world state is slightly changed: > , scale = 1.0 > , box = Box3D { minPoint = makePoint3D (-2,-2,-2) > , maxPoint = makePoint3D (2,2,2) -> , resolution = 0.01 } +> , resolution = 0.03 } > , told = 0 > -- We declare cache directly this time > , cache = objectFunctionFromWorld initialWorld @@ -132,7 +132,8 @@ This way instead of providing `XYFunc`, we provide directly a list of Atoms. > objectFunctionFromWorld :: World -> [YObject] > objectFunctionFromWorld w = [Atoms atomList] > where atomListPositive = -> getObject3DFromShapeFunction (shapeFunc (resolution (box w))) (box w) +> getObject3DFromShapeFunction +> (shapeFunc (resolution (box w))) (box w) > atomList = atomListPositive ++ > map negativeTriangle atomListPositive > negativeTriangle (ColoredTriangle (p1,p2,p3,c)) = diff --git a/06_Mandelbulb/YGL.hs b/06_Mandelbulb/YGL.hs index a4b5c94..f71e49f 100644 --- a/06_Mandelbulb/YGL.hs +++ b/06_Mandelbulb/YGL.hs @@ -70,8 +70,7 @@ zpoint :: Point3D -> Point zpoint (P (_,_,z)) = z makePoint3D :: (Point,Point,Point) -> Point3D -makePoint3D p = P p - +makePoint3D = P instance Num Point3D where (+) (P (ax,ay,az)) (P (bx,by,bz)) = P (ax+bx,ay+by,az+bz) @@ -315,25 +314,21 @@ display worldRef = do scalarFromHex :: String -> Scalar scalarFromHex = (/256) . fst . head . readHex -hexColor :: [Char] -> Color -hexColor ('#':rd:ru:gd:gu:bd:bu:[]) = Color3 (scalarFromHex (rd:ru:[])) - (scalarFromHex (gd:gu:[])) - (scalarFromHex (bd:bu:[])) -hexColor ('#':r:g:b:[]) = hexColor ('#':r:r:g:g:b:b:[]) +hexColor :: String -> Color +hexColor ('#':rd:ru:gd:gu:bd:bu:[]) = Color3 (scalarFromHex [rd,ru]) + (scalarFromHex [gd,gu]) + (scalarFromHex [bd,bu]) +hexColor ('#':r:g:b:[]) = hexColor ['#',r,r,g,g,b,b] hexColor _ = error "Bad color!!!!" makeColor :: Scalar -> Scalar -> Scalar -> Color -makeColor x y z = Color3 x y z +makeColor = Color3 --- -- drawObject :: (YObject obj) => obj -> IO() drawObject :: YObject -> IO() -drawObject shape = do - -- We will print only Triangles - renderPrimitive Triangles $ do - -- solarized base3 color - -- color $ hexColor "#fdf603" - mapM_ drawAtom (atoms shape) +drawObject shape = renderPrimitive Triangles $ + mapM_ drawAtom (atoms shape) -- simply draw an Atom drawAtom :: Atom -> IO ()