Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Rect a = Rect' (Compose Point Range a)
- pattern Rect :: a -> a -> a -> a -> Rect a
- pattern Ranges :: Range a -> Range a -> Rect a
- corners :: Ord a => Rect a -> [Point a]
- corners4 :: Rect a -> NonEmpty (Point a)
- projectRect :: (Ord a, Fractional a) => Rect a -> Rect a -> Rect a -> Rect a
- addRect :: Num a => Rect a -> Rect a -> Rect a
- multRect :: (Ord a, Fractional a) => Rect a -> Rect a -> Rect a
- unitRect :: Fractional a => Rect a
- foldRect :: Ord a => [Rect a] -> Maybe (Rect a)
- addPoint :: Num a => Point a -> Rect a -> Rect a
- rotateRect :: (Floating a, Ord a) => a -> Rect a -> Rect a
- gridR :: (Ord a, Fractional a) => (a -> a) -> Range a -> Int -> [Rect a]
- gridF :: (Ord a, Fractional a) => (Point a -> b) -> Rect a -> Grid (Rect a) -> [(Rect a, b)]
- aspect :: Fractional a => a -> Rect a
- ratio :: Fractional a => Rect a -> a
Documentation
a Point
of Ranges
that form a rectangle in what is often thought of as the XY plane.
>>>
let a = Rect (-1) 1 (-2) 4
>>>
a
Rect -1 1 -2 4>>>
let (Ranges x y) = a
>>>
x
Range -1 1>>>
y
Range -2 4>>>
fmap (+1) (Rect 1 2 3 4)
Rect 2 3 4 5>>>
one :: Rect Double
Rect -0.5 0.5 -0.5 0.5>>>
zero :: Rect Double
Rect Infinity -Infinity Infinity -Infinity
as a Field instance
>>>
Rect 0 1 2 3 + zero
Rect 0.0 1.0 2.0 3.0>>>
Rect 0 1 (-2) (-1) + Rect 2 3 (-5) 3
Rect 0.0 3.0 -5.0 3.0>>>
Rect 1 1 1 1 - one
Rect 0.5 1.0 0.5 1.0>>>
Rect 0 1 0 1 * one
Rect 0.0 1.0 0.0 1.0>>>
Rect 0 1 0 1 / one
Rect 0.0 1.0 0.0 1.0>>>
singleton (Point 1.0 2.0) :: Rect Double
Rect 1.0 1.0 2.0 2.0>>>
abs (Rect 1 0 1 0)
Rect 0.0 1.0 0.0 1.0>>>
sign (Rect 1 0 1 0) == negate one
True
as a Space instance
>>>
project (Rect 0 1 (-1) 0) (Rect 1 4 10 0) (Point 0.5 1)
Point 2.5 -10.0>>>
gridSpace (Rect 0 10 0 1) (Point 2 2)
[Rect 0.0 5.0 0.0 0.5,Rect 0.0 5.0 0.5 1.0,Rect 5.0 10.0 0.0 0.5,Rect 5.0 10.0 0.5 1.0]>>>
grid MidPos (Rect 0 10 0 1) (Point 2 2)
[Point 2.5 0.25,Point 2.5 0.75,Point 7.5 0.25,Point 7.5 0.75]
Instances
corners :: Ord a => Rect a -> [Point a] Source #
create a list of points representing the lower left and upper right corners of a rectangle.
projectRect :: (Ord a, Fractional a) => Rect a -> Rect a -> Rect a -> Rect a Source #
project a Rect from an old range to a new 1
addRect :: Num a => Rect a -> Rect a -> Rect a Source #
Rect projection maths: some sort of affine projection lurking under the hood? > width one = one > mid zero = zero
unitRect :: Fractional a => Rect a Source #
rotateRect :: (Floating a, Ord a) => a -> Rect a -> Rect a Source #
rotate the corners of a Rect by x degrees relative to the origin, and fold to a new Rcet
gridR :: (Ord a, Fractional a) => (a -> a) -> Range a -> Int -> [Rect a] Source #
Create Rects for a formulae y = f(x) across an x range
gridF :: (Ord a, Fractional a) => (Point a -> b) -> Rect a -> Grid (Rect a) -> [(Rect a, b)] Source #
Create values c for Rects data for a formulae c = f(x,y)
aspect :: Fractional a => a -> Rect a Source #
convert a ratio of x-plane : y-plane to a ViewBox with a height of one.
ratio :: Fractional a => Rect a -> a Source #
convert a Rect to a ratio