{-# 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.MediaConvert.Types.Rectangle
-- 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.MediaConvert.Types.Rectangle 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

-- | Use Rectangle to identify a specific area of the video frame.
--
-- /See:/ 'newRectangle' smart constructor.
data Rectangle = Rectangle'
  { -- | Height of rectangle in pixels. Specify only even numbers.
    Rectangle -> Maybe Natural
height :: Prelude.Maybe Prelude.Natural,
    -- | Width of rectangle in pixels. Specify only even numbers.
    Rectangle -> Maybe Natural
width :: Prelude.Maybe Prelude.Natural,
    -- | The distance, in pixels, between the rectangle and the left edge of the
    -- video frame. Specify only even numbers.
    Rectangle -> Maybe Natural
x :: Prelude.Maybe Prelude.Natural,
    -- | The distance, in pixels, between the rectangle and the top edge of the
    -- video frame. Specify only even numbers.
    Rectangle -> Maybe Natural
y :: Prelude.Maybe Prelude.Natural
  }
  deriving (Rectangle -> Rectangle -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rectangle -> Rectangle -> Bool
$c/= :: Rectangle -> Rectangle -> Bool
== :: Rectangle -> Rectangle -> Bool
$c== :: Rectangle -> Rectangle -> Bool
Prelude.Eq, ReadPrec [Rectangle]
ReadPrec Rectangle
Int -> ReadS Rectangle
ReadS [Rectangle]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Rectangle]
$creadListPrec :: ReadPrec [Rectangle]
readPrec :: ReadPrec Rectangle
$creadPrec :: ReadPrec Rectangle
readList :: ReadS [Rectangle]
$creadList :: ReadS [Rectangle]
readsPrec :: Int -> ReadS Rectangle
$creadsPrec :: Int -> ReadS Rectangle
Prelude.Read, Int -> Rectangle -> ShowS
[Rectangle] -> ShowS
Rectangle -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rectangle] -> ShowS
$cshowList :: [Rectangle] -> ShowS
show :: Rectangle -> String
$cshow :: Rectangle -> String
showsPrec :: Int -> Rectangle -> ShowS
$cshowsPrec :: Int -> Rectangle -> ShowS
Prelude.Show, forall x. Rep Rectangle x -> Rectangle
forall x. Rectangle -> Rep Rectangle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Rectangle x -> Rectangle
$cfrom :: forall x. Rectangle -> Rep Rectangle x
Prelude.Generic)

-- |
-- Create a value of 'Rectangle' 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:
--
-- 'height', 'rectangle_height' - Height of rectangle in pixels. Specify only even numbers.
--
-- 'width', 'rectangle_width' - Width of rectangle in pixels. Specify only even numbers.
--
-- 'x', 'rectangle_x' - The distance, in pixels, between the rectangle and the left edge of the
-- video frame. Specify only even numbers.
--
-- 'y', 'rectangle_y' - The distance, in pixels, between the rectangle and the top edge of the
-- video frame. Specify only even numbers.
newRectangle ::
  Rectangle
newRectangle :: Rectangle
newRectangle =
  Rectangle'
    { $sel:height:Rectangle' :: Maybe Natural
height = forall a. Maybe a
Prelude.Nothing,
      $sel:width:Rectangle' :: Maybe Natural
width = forall a. Maybe a
Prelude.Nothing,
      $sel:x:Rectangle' :: Maybe Natural
x = forall a. Maybe a
Prelude.Nothing,
      $sel:y:Rectangle' :: Maybe Natural
y = forall a. Maybe a
Prelude.Nothing
    }

-- | Height of rectangle in pixels. Specify only even numbers.
rectangle_height :: Lens.Lens' Rectangle (Prelude.Maybe Prelude.Natural)
rectangle_height :: Lens' Rectangle (Maybe Natural)
rectangle_height = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rectangle' {Maybe Natural
height :: Maybe Natural
$sel:height:Rectangle' :: Rectangle -> Maybe Natural
height} -> Maybe Natural
height) (\s :: Rectangle
s@Rectangle' {} Maybe Natural
a -> Rectangle
s {$sel:height:Rectangle' :: Maybe Natural
height = Maybe Natural
a} :: Rectangle)

-- | Width of rectangle in pixels. Specify only even numbers.
rectangle_width :: Lens.Lens' Rectangle (Prelude.Maybe Prelude.Natural)
rectangle_width :: Lens' Rectangle (Maybe Natural)
rectangle_width = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rectangle' {Maybe Natural
width :: Maybe Natural
$sel:width:Rectangle' :: Rectangle -> Maybe Natural
width} -> Maybe Natural
width) (\s :: Rectangle
s@Rectangle' {} Maybe Natural
a -> Rectangle
s {$sel:width:Rectangle' :: Maybe Natural
width = Maybe Natural
a} :: Rectangle)

-- | The distance, in pixels, between the rectangle and the left edge of the
-- video frame. Specify only even numbers.
rectangle_x :: Lens.Lens' Rectangle (Prelude.Maybe Prelude.Natural)
rectangle_x :: Lens' Rectangle (Maybe Natural)
rectangle_x = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rectangle' {Maybe Natural
x :: Maybe Natural
$sel:x:Rectangle' :: Rectangle -> Maybe Natural
x} -> Maybe Natural
x) (\s :: Rectangle
s@Rectangle' {} Maybe Natural
a -> Rectangle
s {$sel:x:Rectangle' :: Maybe Natural
x = Maybe Natural
a} :: Rectangle)

-- | The distance, in pixels, between the rectangle and the top edge of the
-- video frame. Specify only even numbers.
rectangle_y :: Lens.Lens' Rectangle (Prelude.Maybe Prelude.Natural)
rectangle_y :: Lens' Rectangle (Maybe Natural)
rectangle_y = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rectangle' {Maybe Natural
y :: Maybe Natural
$sel:y:Rectangle' :: Rectangle -> Maybe Natural
y} -> Maybe Natural
y) (\s :: Rectangle
s@Rectangle' {} Maybe Natural
a -> Rectangle
s {$sel:y:Rectangle' :: Maybe Natural
y = Maybe Natural
a} :: Rectangle)

instance Data.FromJSON Rectangle where
  parseJSON :: Value -> Parser Rectangle
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Rectangle"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural -> Maybe Natural -> Maybe Natural -> Rectangle
Rectangle'
            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
"height")
            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
"width")
            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
"x")
            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
"y")
      )

instance Prelude.Hashable Rectangle where
  hashWithSalt :: Int -> Rectangle -> Int
hashWithSalt Int
_salt Rectangle' {Maybe Natural
y :: Maybe Natural
x :: Maybe Natural
width :: Maybe Natural
height :: Maybe Natural
$sel:y:Rectangle' :: Rectangle -> Maybe Natural
$sel:x:Rectangle' :: Rectangle -> Maybe Natural
$sel:width:Rectangle' :: Rectangle -> Maybe Natural
$sel:height:Rectangle' :: Rectangle -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
height
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
width
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
x
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
y

instance Prelude.NFData Rectangle where
  rnf :: Rectangle -> ()
rnf Rectangle' {Maybe Natural
y :: Maybe Natural
x :: Maybe Natural
width :: Maybe Natural
height :: Maybe Natural
$sel:y:Rectangle' :: Rectangle -> Maybe Natural
$sel:x:Rectangle' :: Rectangle -> Maybe Natural
$sel:width:Rectangle' :: Rectangle -> Maybe Natural
$sel:height:Rectangle' :: Rectangle -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
height
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
width
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
x
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
y

instance Data.ToJSON Rectangle where
  toJSON :: Rectangle -> Value
toJSON Rectangle' {Maybe Natural
y :: Maybe Natural
x :: Maybe Natural
width :: Maybe Natural
height :: Maybe Natural
$sel:y:Rectangle' :: Rectangle -> Maybe Natural
$sel:x:Rectangle' :: Rectangle -> Maybe Natural
$sel:width:Rectangle' :: Rectangle -> Maybe Natural
$sel:height:Rectangle' :: Rectangle -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"height" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
height,
            (Key
"width" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
width,
            (Key
"x" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
x,
            (Key
"y" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
y
          ]
      )