Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include borders of objects in the generated image #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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