Implement combined functions
This commit is contained in:
parent
29a62ecc21
commit
d017ccd848
1 changed files with 7 additions and 7 deletions
|
@ -41,13 +41,13 @@ unitSq = Shape $ \(x, y) ->
|
|||
-}
|
||||
translate :: Vector -> Shape -> Shape
|
||||
translate (dx, dy) s = Shape $ \(x, y) ->
|
||||
error "Fixme"
|
||||
inside s (x + dx, y + dy)
|
||||
|
||||
{- Inverting
|
||||
Inverting a shape i.e. switching outside vs inside
|
||||
-}
|
||||
negate :: Shape -> Shape
|
||||
negate s = error "Fixme"
|
||||
negate s = Shape $ \ (x, y) -> not (inside s (x, y))
|
||||
|
||||
{- General combinator
|
||||
Combining two shapes with a parametric boolean function
|
||||
|
@ -66,19 +66,19 @@ combineBool f s1 s2 = Shape $ \p -> f (f1 p) (f2 p)
|
|||
All points that are in both shapes
|
||||
-}
|
||||
intersect :: Shape -> Shape -> Shape
|
||||
intersect = error "Fixme"
|
||||
intersect s1 s2 = Shape $ \ (x, y) -> all (\ s -> inside s (x, y)) [s1, s2]
|
||||
|
||||
{-
|
||||
All points that in at least one of the shapes
|
||||
-}
|
||||
merge :: Shape -> Shape -> Shape
|
||||
merge = error "Fixme"
|
||||
merge s1 s2 = Shape $ \ (x, y) -> any (\ s -> inside s (x, y)) [s1, s2]
|
||||
|
||||
{-
|
||||
All points in the first shape that are not in the secnond shape
|
||||
All points in the first shape that are not in the second shape
|
||||
-}
|
||||
minus :: Shape -> Shape -> Shape
|
||||
minus = error "Fixme"
|
||||
minus s1 s2 = Shape $ \ (x, y) -> inside s1 (x, y) && not (inside s1 (x, y))
|
||||
|
||||
|
||||
{- Matrix transformations
|
||||
|
@ -170,4 +170,4 @@ iShape = flipX $ merge
|
|||
(stretchY 2 unitSq)
|
||||
(translate (0, 5) unitDisc)
|
||||
|
||||
disc50 = stretch 50 unitDisc
|
||||
disc50 = stretch 50 unitDisc
|
||||
|
|
Loading…
Reference in a new issue