hlinted
This commit is contained in:
parent
8e0e2fc56a
commit
11f3685b54
4 changed files with 17 additions and 21 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)) =
|
||||
|
|
|
@ -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,24 +314,20 @@ 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"
|
||||
drawObject shape = renderPrimitive Triangles $
|
||||
mapM_ drawAtom (atoms shape)
|
||||
|
||||
-- simply draw an Atom
|
||||
|
|
Loading…
Reference in a new issue