----------------------------------------------------------------------
-- |
-- Module      :  Graphics.FieldTrip.Image
-- Copyright   :  (c) Conal Elliott 2008
-- License     :  BSD3
-- 
-- Maintainer  :  conal@conal.net
-- Stability   :  experimental
-- 
-- 2D imagery
----------------------------------------------------------------------

module Graphics.FieldTrip.Image where

import Data.Function (on)
import Control.Applicative

-- import Graphics.Rendering.OpenGL (Color4)

import Data.VectorSpace
import Graphics.FieldTrip.Misc
import Graphics.FieldTrip.Color

-- These types can be generalized to other scalar types, at the cost of
-- lots of type constraints.

type Image o = (R,R) -> o

type ImageC = Image Col
type Region = Image Bool

over :: Binop ImageC
over = liftA2 overC

smallFrac :: R -> Bool
smallFrac = (< 1/2) . fracPart

rings :: Region
rings = smallFrac . magnitude

checker :: Region
-- checker (x,y) = smallFrac x == smallFrac y

checker = uncurry ((==) `on` smallFrac)

-- TODO: