Skip to content

Commit

Permalink
include borders of objects in the generated image
Browse files Browse the repository at this point in the history
test case:
```
    square([10, 10]);
    translate([10, 5])
        square([10, 20]);
}
```
  • Loading branch information
l29ah committed Jun 28, 2019
1 parent 633d46a commit f1351e2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Graphics/Implicit/Export/DiscreteAproxable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-- | A module for retrieving approximate represententations of objects.
module Graphics.Implicit.Export.DiscreteAproxable (DiscreteAproxable, discreteAprox) where

import Prelude((-), (/), ($), (<), map, round, (+), maximum, abs, (*), fromIntegral, max, realToFrac, Int)
import Prelude((-), (/), ($), map, round, (+), maximum, abs, (*), fromIntegral, max, realToFrac, Int)

-- Definitions for our number system, objects, and the things we can use to approximately represent objects.
import Graphics.Implicit.Definitions (, ℝ2, SymbolicObj2, SymbolicObj3, Polyline, Triangle, TriangleMesh(TriangleMesh), NormedTriangleMesh(NormedTriangleMesh))
Expand All @@ -29,6 +29,8 @@ import Graphics.Implicit.Export.RayTrace (Color(Color), Camera(Camera), Light(Li

import Codec.Picture (DynamicImage(ImageRGBA8), PixelRGBA8(PixelRGBA8), generateImage)

import Data.Ord (Ordering(..), compare)

import Data.VectorSpace ((^+^), (^/), (*^), (^-^))

import Data.AffineSpace ((.-^), (.+^))
Expand Down Expand Up @@ -117,5 +119,8 @@ instance DiscreteAproxable SymbolicObj2 DynamicImage where
objColor $ xy (a'-s) (b'-s)]
colorToPixelRGBA8 :: Color -> PixelRGBA8
colorToPixelRGBA8 (Color rr gg bb aa) = PixelRGBA8 rr gg bb aa
objColor p = if obj p < 0 then Color 150 150 160 255 else Color 255 255 255 0
objColor p = case obj p `compare` 0 of
LT -> Color 150 150 160 255
EQ -> Color 0 0 255 255
GT -> Color 255 255 255 0

0 comments on commit f1351e2

Please sign in to comment.