diagrams-lib-1.4.2.2: Embedded domain-specific language for declarative graphics

Copyright(c) 2013 diagrams-lib team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.Query

Contents

Description

A query is a function that maps points in a vector space to values in some monoid. Queries naturally form a monoid, with two queries being combined pointwise.

Synopsis

Queries

newtype Query (v :: * -> *) n m :: (* -> *) -> * -> * -> * #

A query is a function that maps points in a vector space to values in some monoid. Queries naturally form a monoid, with two queries being combined pointwise.

The idea for annotating diagrams with monoidal queries came from the graphics-drawingcombinators package, http://hackage.haskell.org/package/graphics-drawingcombinators.

Constructors

Query 

Fields

Instances

Functor v => Corepresentable (Query v) 

Associated Types

type Corep (Query v :: * -> * -> *) :: * -> * #

Methods

cotabulate :: (Corep (Query v) d -> c) -> Query v d c #

Functor v => Profunctor (Query v) 

Methods

dimap :: (a -> b) -> (c -> d) -> Query v b c -> Query v a d #

lmap :: (a -> b) -> Query v b c -> Query v a c #

rmap :: (b -> c) -> Query v a b -> Query v a c #

(#.) :: Coercible * c b => (b -> c) -> Query v a b -> Query v a c #

(.#) :: Coercible * b a => Query v b c -> (a -> b) -> Query v a c #

Functor v => Closed (Query v) 

Methods

closed :: Query v a b -> Query v (x -> a) (x -> b) #

Functor v => Costrong (Query v) 

Methods

unfirst :: Query v (a, d) (b, d) -> Query v a b #

unsecond :: Query v (d, a) (d, b) -> Query v a b #

Functor v => Cosieve (Query v) (Point v) 

Methods

cosieve :: Query v a b -> Point v a -> b #

Monad (Query v n) 

Methods

(>>=) :: Query v n a -> (a -> Query v n b) -> Query v n b #

(>>) :: Query v n a -> Query v n b -> Query v n b #

return :: a -> Query v n a #

fail :: String -> Query v n a #

Functor (Query v n) 

Methods

fmap :: (a -> b) -> Query v n a -> Query v n b #

(<$) :: a -> Query v n b -> Query v n a #

Applicative (Query v n) 

Methods

pure :: a -> Query v n a #

(<*>) :: Query v n (a -> b) -> Query v n a -> Query v n b #

liftA2 :: (a -> b -> c) -> Query v n a -> Query v n b -> Query v n c #

(*>) :: Query v n a -> Query v n b -> Query v n b #

(<*) :: Query v n a -> Query v n b -> Query v n a #

Distributive (Query v n) 

Methods

distribute :: Functor f => f (Query v n a) -> Query v n (f a) #

collect :: Functor f => (a -> Query v n b) -> f a -> Query v n (f b) #

distributeM :: Monad m => m (Query v n a) -> Query v n (m a) #

collectM :: Monad m => (a -> Query v n b) -> m a -> Query v n (m b) #

Representable (Query v n) 

Associated Types

type Rep (Query v n :: * -> *) :: * #

Methods

tabulate :: (Rep (Query v n) -> a) -> Query v n a #

index :: Query v n a -> Rep (Query v n) -> a #

Semigroup m => Semigroup (Query v n m) 

Methods

(<>) :: Query v n m -> Query v n m -> Query v n m #

sconcat :: NonEmpty (Query v n m) -> Query v n m #

stimes :: Integral b => b -> Query v n m -> Query v n m #

Monoid m => Monoid (Query v n m) 

Methods

mempty :: Query v n m #

mappend :: Query v n m -> Query v n m -> Query v n m #

mconcat :: [Query v n m] -> Query v n m #

(Additive v, Num n) => Transformable (Query v n m) 

Methods

transform :: Transformation (V (Query v n m)) (N (Query v n m)) -> Query v n m -> Query v n m #

(Additive v, Num n) => HasOrigin (Query v n m) 

Methods

moveOriginTo :: Point (V (Query v n m)) (N (Query v n m)) -> Query v n m -> Query v n m #

Wrapped (Query v n m) 

Associated Types

type Unwrapped (Query v n m) :: * #

Methods

_Wrapped' :: Iso' (Query v n m) (Unwrapped (Query v n m)) #

HasQuery (Query v n m) m Source # 

Methods

getQuery :: Query v n m -> Query (V (Query v n m)) (N (Query v n m)) m Source #

Rewrapped (Query v a m) (Query v' a' m') 
type Corep (Query v) 
type Corep (Query v) = Point v
type Rep (Query v n) 
type Rep (Query v n) = Point v n
type V (Query v n m) 
type V (Query v n m) = v
type N (Query v n m) 
type N (Query v n m) = n
type Unwrapped (Query v n m) 
type Unwrapped (Query v n m) = Point v n -> m

class HasQuery t m | t -> m where Source #

Types which can answer a Query about points inside the geometric object.

If t and m are both a Semigroups, getQuery should satisfy

getQuery (t1 <> t2) = getQuery t1 <> getQuery t2

Minimal complete definition

getQuery

Methods

getQuery :: t -> Query (V t) (N t) m Source #

Extract the query of an object.

Instances

(Floating n, Ord n) => HasQuery (CSG n) Any Source # 

Methods

getQuery :: CSG n -> Query (V (CSG n)) (N (CSG n)) Any Source #

OrderedField n => HasQuery (Frustum n) Any Source # 

Methods

getQuery :: Frustum n -> Query (V (Frustum n)) (N (Frustum n)) Any Source #

(Num n, Ord n) => HasQuery (Box n) Any Source # 

Methods

getQuery :: Box n -> Query (V (Box n)) (N (Box n)) Any Source #

(Num n, Ord n) => HasQuery (Ellipsoid n) Any Source # 

Methods

getQuery :: Ellipsoid n -> Query (V (Ellipsoid n)) (N (Ellipsoid n)) Any Source #

RealFloat n => HasQuery (Clip n) All Source #

A point inside a clip if the point is in All invididual clipping paths.

Methods

getQuery :: Clip n -> Query (V (Clip n)) (N (Clip n)) All Source #

RealFloat n => HasQuery (DImage n a) Any Source # 

Methods

getQuery :: DImage n a -> Query (V (DImage n a)) (N (DImage n a)) Any Source #

(Additive v, Foldable v, Ord n) => HasQuery (BoundingBox v n) Any Source # 

Methods

getQuery :: BoundingBox v n -> Query (V (BoundingBox v n)) (N (BoundingBox v n)) Any Source #

HasQuery (Query v n m) m Source # 

Methods

getQuery :: Query v n m -> Query (V (Query v n m)) (N (Query v n m)) m Source #

Monoid m => HasQuery (QDiagram b v n m) m Source # 

Methods

getQuery :: QDiagram b v n m -> Query (V (QDiagram b v n m)) (N (QDiagram b v n m)) m Source #

sample :: HasQuery t m => t -> Point (V t) (N t) -> m Source #

Sample a diagram's query function at a given point.

sample :: QDiagram b v n m -> Point v n -> m
sample :: Query v n m      -> Point v n -> m
sample :: BoundingBox v n  -> Point v n -> Any
sample :: Path V2 Double   -> Point v n -> Crossings

inquire :: HasQuery t Any => t -> Point (V t) (N t) -> Bool Source #

Test if a point is not equal to mempty.

inquire :: QDiagram b v n Any -> Point v n -> Bool
inquire :: Query v n Any      -> Point v n -> Bool
inquire :: BoundingBox v n  -> Point v n -> Bool

Queries on diagrams

query :: Monoid m => QDiagram b v n m -> Query v n m #

Get the query function associated with a diagram.

value :: Monoid m => m -> QDiagram b v n Any -> QDiagram b v n m Source #

Set the query value for True points in a diagram (i.e. points "inquire" the diagram); False points will be set to mempty.

resetValue :: (Eq m, Monoid m) => QDiagram b v n m -> QDiagram b v n Any Source #

Reset the query values of a diagram to True/False: any values equal to mempty are set to False; any other values are set to True.

clearValue :: QDiagram b v n m -> QDiagram b v n Any Source #

Set all the query values of a diagram to False.