diff options
author | Griffin Smith <root@gws.fyi> | 2020-05-10T23·44-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2020-05-10T23·44-0400 |
commit | 2320cfa8cd2540cd0caf91f2e7cdc81045c9504c (patch) | |
tree | fb631f55079e7154e79fb2526784dc6123146bc8 /test/Xanthous | |
parent | 78a323ec7a2be18325604829122b7bf95e232b9b (diff) |
Use open circles to generate filled circles
Rather than leaning on rasterific to generate filled circles for us, instead start with an open circle, then fill it by scanning line-by-line and filling in points that are "inside" of the circle, based on keeping track with a boolean. Also adds a couple of helper functions for displaying these kinda "boolean graphics" things we're passing around, as sets of points.
Diffstat (limited to 'test/Xanthous')
-rw-r--r-- | test/Xanthous/Util/GraphicsSpec.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/test/Xanthous/Util/GraphicsSpec.hs b/test/Xanthous/Util/GraphicsSpec.hs index a1eaf73e2845..ff99d1073840 100644 --- a/test/Xanthous/Util/GraphicsSpec.hs +++ b/test/Xanthous/Util/GraphicsSpec.hs @@ -5,6 +5,7 @@ import Test.Prelude hiding (head) import Xanthous.Util.Graphics import Xanthous.Util import Data.List (head) +import Data.Set (isSubsetOf) -------------------------------------------------------------------------------- main :: IO () @@ -40,12 +41,18 @@ test = testGroup "Xanthous.Util.Graphics" , (12,0), (12,1),(12,2),(12,3),(12,4) ] - -- , testProperty "is a subset of filledCircle" $ \center radius -> - -- let circ = circle @Int center radius - -- filledCirc = filledCircle center radius - -- in counterexample ( "circle: " <> show circ - -- <> "\nfilledCircle: " <> show filledCirc) - -- $ setFromList circ `isSubsetOf` setFromList filledCirc + ] + , testGroup "filledCircle" + [ testProperty "is a superset of circle" $ \center radius -> + let circ = circle @Int center radius + filledCirc = filledCircle center radius + in counterexample ( "circle: " <> show circ + <> "\nfilledCircle: " <> show filledCirc) + $ setFromList circ `isSubsetOf` setFromList filledCirc + -- TODO later + -- , testProperty "is always contiguous" $ \center radius -> + -- let filledCirc = filledCircle center radius + -- in counterexample (renderBooleanGraphics filledCirc) $ ] , testGroup "line" [ testProperty "starts and ends at the start and end points" $ \start end -> |