{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
module Diagrams.TwoD.Size
(
width, height
, extentX, extentY
, mkSizeSpec2D
, mkWidth
, mkHeight
, dims2D
) where
import Diagrams.Core
import Diagrams.Core.Envelope
import Diagrams.Size
import Diagrams.TwoD.Types
import Diagrams.TwoD.Vector
width :: (InSpace V2 n a, Enveloped a) => a -> n
width :: forall n a. (InSpace V2 n a, Enveloped a) => a -> n
width = V2 n -> a -> n
forall a (v :: * -> *) n.
(V a ~ v, N a ~ n, Enveloped a) =>
v n -> a -> n
diameter V2 n
forall (v :: * -> *) n. (R1 v, Additive v, Num n) => v n
unitX
height :: (InSpace V2 n a, Enveloped a) => a -> n
height :: forall n a. (InSpace V2 n a, Enveloped a) => a -> n
height = V2 n -> a -> n
forall a (v :: * -> *) n.
(V a ~ v, N a ~ n, Enveloped a) =>
v n -> a -> n
diameter V2 n
forall (v :: * -> *) n. (R2 v, Additive v, Num n) => v n
unitY
extentX :: (InSpace v n a, R1 v, Enveloped a) => a -> Maybe (n, n)
extentX :: forall (v :: * -> *) n a.
(InSpace v n a, R1 v, Enveloped a) =>
a -> Maybe (n, n)
extentX = v n -> a -> Maybe (n, n)
forall a (v :: * -> *) n.
(V a ~ v, N a ~ n, Enveloped a) =>
v n -> a -> Maybe (n, n)
extent v n
forall (v :: * -> *) n. (R1 v, Additive v, Num n) => v n
unitX
extentY :: (InSpace v n a, R2 v, Enveloped a) => a -> Maybe (n, n)
extentY :: forall (v :: * -> *) n a.
(InSpace v n a, R2 v, Enveloped a) =>
a -> Maybe (n, n)
extentY = v n -> a -> Maybe (n, n)
forall a (v :: * -> *) n.
(V a ~ v, N a ~ n, Enveloped a) =>
v n -> a -> Maybe (n, n)
extent v n
forall (v :: * -> *) n. (R2 v, Additive v, Num n) => v n
unitY
mkSizeSpec2D :: Num n => Maybe n -> Maybe n -> SizeSpec V2 n
mkSizeSpec2D :: forall n. Num n => Maybe n -> Maybe n -> SizeSpec V2 n
mkSizeSpec2D Maybe n
x Maybe n
y = V2 (Maybe n) -> SizeSpec V2 n
forall (v :: * -> *) n.
(Functor v, Num n) =>
v (Maybe n) -> SizeSpec v n
mkSizeSpec (Maybe n -> Maybe n -> V2 (Maybe n)
forall a. a -> a -> V2 a
V2 Maybe n
x Maybe n
y)
dims2D :: n -> n -> SizeSpec V2 n
dims2D :: forall n. n -> n -> SizeSpec V2 n
dims2D n
x n
y = V2 n -> SizeSpec V2 n
forall (v :: * -> *) n. v n -> SizeSpec v n
dims (n -> n -> V2 n
forall a. a -> a -> V2 a
V2 n
x n
y)
mkWidth :: Num n => n -> SizeSpec V2 n
mkWidth :: forall n. Num n => n -> SizeSpec V2 n
mkWidth n
w = V2 n -> SizeSpec V2 n
forall (v :: * -> *) n. v n -> SizeSpec v n
dims (n -> n -> V2 n
forall a. a -> a -> V2 a
V2 n
w n
0)
mkHeight :: Num n => n -> SizeSpec V2 n
mkHeight :: forall n. Num n => n -> SizeSpec V2 n
mkHeight n
h = V2 n -> SizeSpec V2 n
forall (v :: * -> *) n. v n -> SizeSpec v n
dims (n -> n -> V2 n
forall a. a -> a -> V2 a
V2 n
0 n
h)