packages feed

diagrams-lib-1.2.0.3 / src / Diagrams / ThreeD / Light.hs

{-# LANGUAGE DeriveDataTypeable    #-}{-# LANGUAGE FlexibleContexts      #-}{-# LANGUAGE MultiParamTypeClasses #-}{-# LANGUAGE TypeFamilies          #-}------------------------------------------------------------------------------- |-- Module      :  Diagrams.ThreeD.Render-- Copyright   :  (c) 2013 diagrams-lib team (see LICENSE)-- License     :  BSD-style (see LICENSE)-- Maintainer  :  diagrams-discuss@googlegroups.com---- Types to specify lighting for 3D rendering.-------------------------------------------------------------------------------module Diagrams.ThreeD.Light whereimport           Data.Colourimport           Data.Monoidimport           Data.Typeableimport           Diagrams.Coreimport           Diagrams.ThreeD.Typesdata PointLight = PointLight P3 (Colour Double)  deriving Typeabledata ParallelLight = ParallelLight R3 (Colour Double)  deriving Typeabletype instance V PointLight = R3type instance V ParallelLight = R3instance Transformable PointLight where    transform t (PointLight p c) = PointLight (transform t p) cinstance Transformable ParallelLight where    transform t (ParallelLight v c) = ParallelLight (transform t v) c-- | Construct a Diagram with a single PointLight at the origin, which-- takes up no space.pointLight :: (Backend b R3, Renderable PointLight b)              => Colour Double -- ^ The color of the light              -> Diagram b R3pointLight c = mkQD (Prim $ PointLight origin c) mempty mempty mempty               (Query . const . Any $ False)-- | Construct a Diagram with a single ParallelLight, which takes up no space.parallelLight :: (Backend b R3, Renderable ParallelLight b)                 => Direction -- ^ The direction in which the light travels.                 -> Colour Double -- ^ The color of the light.                 -> Diagram b R3parallelLight d c = mkQD (Prim $ ParallelLight (fromDirection d) c)                    mempty mempty mempty (Query . const . Any $ False)