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.
This commit is contained in:
parent
78a323ec7a
commit
2320cfa8cd
2 changed files with 80 additions and 42 deletions
|
@ -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 ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue