-----------------------------------------------------------------------------
--
-- Module      :  $Headers
-- Copyright   :  (c) 2021 Brian W Bush
-- License     :  MIT
--
-- Maintainer  :  Brian W Bush <code@functionally.io>
-- Stability   :  Experimental
-- Portability :  Portable
--
-- | Types for pig images.
--
-----------------------------------------------------------------------------


{-# LANGUAGE MultiParamTypeClasses #-}


module Pigy.Image.Types (
-- * Chromosomes
  Chromosome
-- * Phenotype
, Phenotype(..)
, Phenable(..)
-- * Upgrades
, Upgradeable(..)
) where


import Codec.Picture (PixelRGBA8(..))


-- | The chromosome.
type Chromosome = String


-- | An upgradeable object.
class Upgradeable g h where
  -- | Upgrade an object.
  upgrade :: g -- ^ The original object.
          -> h -- ^ The upgraded object.


-- | The phenotype for pig images.
data Phenotype =
  Phenotype
  {
    Phenotype -> Float
skinHue     :: Float          -- ^ The skin hue.
  , Phenotype -> PixelRGBA8
eyeColor    :: PixelRGBA8     -- ^ The eye color.
  , Phenotype -> PixelRGBA8
pupilColor  :: PixelRGBA8     -- ^ The pupil color.
  , Phenotype -> PixelRGBA8
noseColor   :: PixelRGBA8     -- ^ The nose color.
  , Phenotype -> Float
aspect      :: Float          -- ^ The overall aspect ratio.
  , Phenotype -> (Float, Float)
headScale   :: (Float, Float) -- ^ The head scale.
  , Phenotype -> (Float, Float)
eyeScale    :: (Float, Float) -- ^ The eye scale.
  , Phenotype -> (Float, Float)
noseScale   :: (Float, Float) -- ^ The nose scale.
  , Phenotype -> (Float, Float)
earScale    :: (Float, Float) -- ^ The ear scale.
  , Phenotype -> Float
bodyScale   :: Float          -- ^ The body scale.
  , Phenotype -> Float
eyeAngle    :: Float          -- ^ The radial angle of the pupil.
  , Phenotype -> Float
eyeFraction :: Float          -- ^ The radial position of the pupil.
  }
    deriving (Phenotype -> Phenotype -> Bool
(Phenotype -> Phenotype -> Bool)
-> (Phenotype -> Phenotype -> Bool) -> Eq Phenotype
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Phenotype -> Phenotype -> Bool
$c/= :: Phenotype -> Phenotype -> Bool
== :: Phenotype -> Phenotype -> Bool
$c== :: Phenotype -> Phenotype -> Bool
Eq, Eq Phenotype
Eq Phenotype
-> (Phenotype -> Phenotype -> Ordering)
-> (Phenotype -> Phenotype -> Bool)
-> (Phenotype -> Phenotype -> Bool)
-> (Phenotype -> Phenotype -> Bool)
-> (Phenotype -> Phenotype -> Bool)
-> (Phenotype -> Phenotype -> Phenotype)
-> (Phenotype -> Phenotype -> Phenotype)
-> Ord Phenotype
Phenotype -> Phenotype -> Bool
Phenotype -> Phenotype -> Ordering
Phenotype -> Phenotype -> Phenotype
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Phenotype -> Phenotype -> Phenotype
$cmin :: Phenotype -> Phenotype -> Phenotype
max :: Phenotype -> Phenotype -> Phenotype
$cmax :: Phenotype -> Phenotype -> Phenotype
>= :: Phenotype -> Phenotype -> Bool
$c>= :: Phenotype -> Phenotype -> Bool
> :: Phenotype -> Phenotype -> Bool
$c> :: Phenotype -> Phenotype -> Bool
<= :: Phenotype -> Phenotype -> Bool
$c<= :: Phenotype -> Phenotype -> Bool
< :: Phenotype -> Phenotype -> Bool
$c< :: Phenotype -> Phenotype -> Bool
compare :: Phenotype -> Phenotype -> Ordering
$ccompare :: Phenotype -> Phenotype -> Ordering
$cp1Ord :: Eq Phenotype
Ord, Int -> Phenotype -> ShowS
[Phenotype] -> ShowS
Phenotype -> String
(Int -> Phenotype -> ShowS)
-> (Phenotype -> String)
-> ([Phenotype] -> ShowS)
-> Show Phenotype
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Phenotype] -> ShowS
$cshowList :: [Phenotype] -> ShowS
show :: Phenotype -> String
$cshow :: Phenotype -> String
showsPrec :: Int -> Phenotype -> ShowS
$cshowsPrec :: Int -> Phenotype -> ShowS
Show)


-- | Conversion to phenotype.
class Phenable g where
  -- | Convert to a phenotype.
  toPhenotype :: g         -- ^ The datum.
              -> Phenotype -- ^ The phenotype.