From 2320cfa8cd2540cd0caf91f2e7cdc81045c9504c Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 10 May 2020 19:44:30 -0400 Subject: 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. --- test/Xanthous/Util/GraphicsSpec.hs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'test') 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 -> -- cgit 1.4.1