{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Rekognition.Types.DominantColor
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Rekognition.Types.DominantColor where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A description of the dominant colors in an image.
--
-- /See:/ 'newDominantColor' smart constructor.
data DominantColor = DominantColor'
  { -- | The Blue RGB value for a dominant color.
    DominantColor -> Maybe Natural
blue :: Prelude.Maybe Prelude.Natural,
    -- | The CSS color name of a dominant color.
    DominantColor -> Maybe Text
cSSColor :: Prelude.Maybe Prelude.Text,
    -- | The Green RGB value for a dominant color.
    DominantColor -> Maybe Natural
green :: Prelude.Maybe Prelude.Natural,
    -- | The Hex code equivalent of the RGB values for a dominant color.
    DominantColor -> Maybe Text
hexCode :: Prelude.Maybe Prelude.Text,
    -- | The percentage of image pixels that have a given dominant color.
    DominantColor -> Maybe Double
pixelPercent :: Prelude.Maybe Prelude.Double,
    -- | The Red RGB value for a dominant color.
    DominantColor -> Maybe Natural
red :: Prelude.Maybe Prelude.Natural,
    -- | One of 12 simplified color names applied to a dominant color.
    DominantColor -> Maybe Text
simplifiedColor :: Prelude.Maybe Prelude.Text
  }
  deriving (DominantColor -> DominantColor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DominantColor -> DominantColor -> Bool
$c/= :: DominantColor -> DominantColor -> Bool
== :: DominantColor -> DominantColor -> Bool
$c== :: DominantColor -> DominantColor -> Bool
Prelude.Eq, ReadPrec [DominantColor]
ReadPrec DominantColor
Int -> ReadS DominantColor
ReadS [DominantColor]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DominantColor]
$creadListPrec :: ReadPrec [DominantColor]
readPrec :: ReadPrec DominantColor
$creadPrec :: ReadPrec DominantColor
readList :: ReadS [DominantColor]
$creadList :: ReadS [DominantColor]
readsPrec :: Int -> ReadS DominantColor
$creadsPrec :: Int -> ReadS DominantColor
Prelude.Read, Int -> DominantColor -> ShowS
[DominantColor] -> ShowS
DominantColor -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DominantColor] -> ShowS
$cshowList :: [DominantColor] -> ShowS
show :: DominantColor -> String
$cshow :: DominantColor -> String
showsPrec :: Int -> DominantColor -> ShowS
$cshowsPrec :: Int -> DominantColor -> ShowS
Prelude.Show, forall x. Rep DominantColor x -> DominantColor
forall x. DominantColor -> Rep DominantColor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DominantColor x -> DominantColor
$cfrom :: forall x. DominantColor -> Rep DominantColor x
Prelude.Generic)

-- |
-- Create a value of 'DominantColor' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'blue', 'dominantColor_blue' - The Blue RGB value for a dominant color.
--
-- 'cSSColor', 'dominantColor_cSSColor' - The CSS color name of a dominant color.
--
-- 'green', 'dominantColor_green' - The Green RGB value for a dominant color.
--
-- 'hexCode', 'dominantColor_hexCode' - The Hex code equivalent of the RGB values for a dominant color.
--
-- 'pixelPercent', 'dominantColor_pixelPercent' - The percentage of image pixels that have a given dominant color.
--
-- 'red', 'dominantColor_red' - The Red RGB value for a dominant color.
--
-- 'simplifiedColor', 'dominantColor_simplifiedColor' - One of 12 simplified color names applied to a dominant color.
newDominantColor ::
  DominantColor
newDominantColor :: DominantColor
newDominantColor =
  DominantColor'
    { $sel:blue:DominantColor' :: Maybe Natural
blue = forall a. Maybe a
Prelude.Nothing,
      $sel:cSSColor:DominantColor' :: Maybe Text
cSSColor = forall a. Maybe a
Prelude.Nothing,
      $sel:green:DominantColor' :: Maybe Natural
green = forall a. Maybe a
Prelude.Nothing,
      $sel:hexCode:DominantColor' :: Maybe Text
hexCode = forall a. Maybe a
Prelude.Nothing,
      $sel:pixelPercent:DominantColor' :: Maybe Double
pixelPercent = forall a. Maybe a
Prelude.Nothing,
      $sel:red:DominantColor' :: Maybe Natural
red = forall a. Maybe a
Prelude.Nothing,
      $sel:simplifiedColor:DominantColor' :: Maybe Text
simplifiedColor = forall a. Maybe a
Prelude.Nothing
    }

-- | The Blue RGB value for a dominant color.
dominantColor_blue :: Lens.Lens' DominantColor (Prelude.Maybe Prelude.Natural)
dominantColor_blue :: Lens' DominantColor (Maybe Natural)
dominantColor_blue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DominantColor' {Maybe Natural
blue :: Maybe Natural
$sel:blue:DominantColor' :: DominantColor -> Maybe Natural
blue} -> Maybe Natural
blue) (\s :: DominantColor
s@DominantColor' {} Maybe Natural
a -> DominantColor
s {$sel:blue:DominantColor' :: Maybe Natural
blue = Maybe Natural
a} :: DominantColor)

-- | The CSS color name of a dominant color.
dominantColor_cSSColor :: Lens.Lens' DominantColor (Prelude.Maybe Prelude.Text)
dominantColor_cSSColor :: Lens' DominantColor (Maybe Text)
dominantColor_cSSColor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DominantColor' {Maybe Text
cSSColor :: Maybe Text
$sel:cSSColor:DominantColor' :: DominantColor -> Maybe Text
cSSColor} -> Maybe Text
cSSColor) (\s :: DominantColor
s@DominantColor' {} Maybe Text
a -> DominantColor
s {$sel:cSSColor:DominantColor' :: Maybe Text
cSSColor = Maybe Text
a} :: DominantColor)

-- | The Green RGB value for a dominant color.
dominantColor_green :: Lens.Lens' DominantColor (Prelude.Maybe Prelude.Natural)
dominantColor_green :: Lens' DominantColor (Maybe Natural)
dominantColor_green = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DominantColor' {Maybe Natural
green :: Maybe Natural
$sel:green:DominantColor' :: DominantColor -> Maybe Natural
green} -> Maybe Natural
green) (\s :: DominantColor
s@DominantColor' {} Maybe Natural
a -> DominantColor
s {$sel:green:DominantColor' :: Maybe Natural
green = Maybe Natural
a} :: DominantColor)

-- | The Hex code equivalent of the RGB values for a dominant color.
dominantColor_hexCode :: Lens.Lens' DominantColor (Prelude.Maybe Prelude.Text)
dominantColor_hexCode :: Lens' DominantColor (Maybe Text)
dominantColor_hexCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DominantColor' {Maybe Text
hexCode :: Maybe Text
$sel:hexCode:DominantColor' :: DominantColor -> Maybe Text
hexCode} -> Maybe Text
hexCode) (\s :: DominantColor
s@DominantColor' {} Maybe Text
a -> DominantColor
s {$sel:hexCode:DominantColor' :: Maybe Text
hexCode = Maybe Text
a} :: DominantColor)

-- | The percentage of image pixels that have a given dominant color.
dominantColor_pixelPercent :: Lens.Lens' DominantColor (Prelude.Maybe Prelude.Double)
dominantColor_pixelPercent :: Lens' DominantColor (Maybe Double)
dominantColor_pixelPercent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DominantColor' {Maybe Double
pixelPercent :: Maybe Double
$sel:pixelPercent:DominantColor' :: DominantColor -> Maybe Double
pixelPercent} -> Maybe Double
pixelPercent) (\s :: DominantColor
s@DominantColor' {} Maybe Double
a -> DominantColor
s {$sel:pixelPercent:DominantColor' :: Maybe Double
pixelPercent = Maybe Double
a} :: DominantColor)

-- | The Red RGB value for a dominant color.
dominantColor_red :: Lens.Lens' DominantColor (Prelude.Maybe Prelude.Natural)
dominantColor_red :: Lens' DominantColor (Maybe Natural)
dominantColor_red = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DominantColor' {Maybe Natural
red :: Maybe Natural
$sel:red:DominantColor' :: DominantColor -> Maybe Natural
red} -> Maybe Natural
red) (\s :: DominantColor
s@DominantColor' {} Maybe Natural
a -> DominantColor
s {$sel:red:DominantColor' :: Maybe Natural
red = Maybe Natural
a} :: DominantColor)

-- | One of 12 simplified color names applied to a dominant color.
dominantColor_simplifiedColor :: Lens.Lens' DominantColor (Prelude.Maybe Prelude.Text)
dominantColor_simplifiedColor :: Lens' DominantColor (Maybe Text)
dominantColor_simplifiedColor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DominantColor' {Maybe Text
simplifiedColor :: Maybe Text
$sel:simplifiedColor:DominantColor' :: DominantColor -> Maybe Text
simplifiedColor} -> Maybe Text
simplifiedColor) (\s :: DominantColor
s@DominantColor' {} Maybe Text
a -> DominantColor
s {$sel:simplifiedColor:DominantColor' :: Maybe Text
simplifiedColor = Maybe Text
a} :: DominantColor)

instance Data.FromJSON DominantColor where
  parseJSON :: Value -> Parser DominantColor
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DominantColor"
      ( \Object
x ->
          Maybe Natural
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> Maybe Double
-> Maybe Natural
-> Maybe Text
-> DominantColor
DominantColor'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Blue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CSSColor")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Green")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"HexCode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"PixelPercent")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Red")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SimplifiedColor")
      )

instance Prelude.Hashable DominantColor where
  hashWithSalt :: Int -> DominantColor -> Int
hashWithSalt Int
_salt DominantColor' {Maybe Double
Maybe Natural
Maybe Text
simplifiedColor :: Maybe Text
red :: Maybe Natural
pixelPercent :: Maybe Double
hexCode :: Maybe Text
green :: Maybe Natural
cSSColor :: Maybe Text
blue :: Maybe Natural
$sel:simplifiedColor:DominantColor' :: DominantColor -> Maybe Text
$sel:red:DominantColor' :: DominantColor -> Maybe Natural
$sel:pixelPercent:DominantColor' :: DominantColor -> Maybe Double
$sel:hexCode:DominantColor' :: DominantColor -> Maybe Text
$sel:green:DominantColor' :: DominantColor -> Maybe Natural
$sel:cSSColor:DominantColor' :: DominantColor -> Maybe Text
$sel:blue:DominantColor' :: DominantColor -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
blue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
cSSColor
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
green
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hexCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
pixelPercent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
red
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
simplifiedColor

instance Prelude.NFData DominantColor where
  rnf :: DominantColor -> ()
rnf DominantColor' {Maybe Double
Maybe Natural
Maybe Text
simplifiedColor :: Maybe Text
red :: Maybe Natural
pixelPercent :: Maybe Double
hexCode :: Maybe Text
green :: Maybe Natural
cSSColor :: Maybe Text
blue :: Maybe Natural
$sel:simplifiedColor:DominantColor' :: DominantColor -> Maybe Text
$sel:red:DominantColor' :: DominantColor -> Maybe Natural
$sel:pixelPercent:DominantColor' :: DominantColor -> Maybe Double
$sel:hexCode:DominantColor' :: DominantColor -> Maybe Text
$sel:green:DominantColor' :: DominantColor -> Maybe Natural
$sel:cSSColor:DominantColor' :: DominantColor -> Maybe Text
$sel:blue:DominantColor' :: DominantColor -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
blue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
cSSColor
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
green
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hexCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
pixelPercent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
red
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
simplifiedColor