1111-- | A module for retrieving approximate represententations of objects.
1212module Graphics.Implicit.Export.DiscreteAproxable (DiscreteAproxable , discreteAprox ) where
1313
14- import Prelude ((-) , (/) , ($) , (<) , map , round , (+) , maximum , abs , (*) , fromIntegral , max , realToFrac , Int )
14+ import Prelude ((-) , (/) , ($) , map , round , (+) , maximum , abs , (*) , fromIntegral , max , realToFrac , Int )
1515
1616-- Definitions for our number system, objects, and the things we can use to approximately represent objects.
1717import Graphics.Implicit.Definitions (ℝ , ℝ2 , SymbolicObj2 , SymbolicObj3 , Polyline , Triangle , TriangleMesh (TriangleMesh ), NormedTriangleMesh (NormedTriangleMesh ))
@@ -29,6 +29,8 @@ import Graphics.Implicit.Export.RayTrace (Color(Color), Camera(Camera), Light(Li
2929
3030import Codec.Picture (DynamicImage (ImageRGBA8 ), PixelRGBA8 (PixelRGBA8 ), generateImage )
3131
32+ import Data.Ord (Ordering (.. ), compare )
33+
3234import Data.VectorSpace ((^+^) , (^/) , (*^) , (^-^) )
3335
3436import Data.AffineSpace ((.-^) , (.+^) )
@@ -117,5 +119,8 @@ instance DiscreteAproxable SymbolicObj2 DynamicImage where
117119 objColor $ xy (a'- s) (b'- s)]
118120 colorToPixelRGBA8 :: Color -> PixelRGBA8
119121 colorToPixelRGBA8 (Color rr gg bb aa) = PixelRGBA8 rr gg bb aa
120- objColor p = if obj p < 0 then Color 150 150 160 255 else Color 255 255 255 0
122+ objColor p = case obj p `compare` 0 of
123+ LT -> Color 150 150 160 255
124+ EQ -> Color 0 0 255 255
125+ GT -> Color 255 255 255 0
121126
0 commit comments