{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaConvert.Types.Rectangle where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(Rectangle -> Rectangle -> Bool)
-> (Rectangle -> Rectangle -> Bool) -> Eq Rectangle
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]
(Int -> ReadS Rectangle)
-> ReadS [Rectangle]
-> ReadPrec Rectangle
-> ReadPrec [Rectangle]
-> Read 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
(Int -> Rectangle -> ShowS)
-> (Rectangle -> String)
-> ([Rectangle] -> ShowS)
-> Show Rectangle
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. Rectangle -> Rep Rectangle x)
-> (forall x. Rep Rectangle x -> Rectangle) -> Generic Rectangle
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' :: Maybe Natural
-> Maybe Natural -> Maybe Natural -> Maybe Natural -> Rectangle
Rectangle'
    { $sel:height:Rectangle' :: Maybe Natural
height = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:width:Rectangle' :: Maybe Natural
width = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:x:Rectangle' :: Maybe Natural
x = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:y:Rectangle' :: Maybe Natural
y = Maybe Natural
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 :: (Maybe Natural -> f (Maybe Natural)) -> Rectangle -> f Rectangle
rectangle_height = (Rectangle -> Maybe Natural)
-> (Rectangle -> Maybe Natural -> Rectangle)
-> Lens Rectangle Rectangle (Maybe Natural) (Maybe Natural)
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 :: (Maybe Natural -> f (Maybe Natural)) -> Rectangle -> f Rectangle
rectangle_width = (Rectangle -> Maybe Natural)
-> (Rectangle -> Maybe Natural -> Rectangle)
-> Lens Rectangle Rectangle (Maybe Natural) (Maybe Natural)
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 :: (Maybe Natural -> f (Maybe Natural)) -> Rectangle -> f Rectangle
rectangle_x = (Rectangle -> Maybe Natural)
-> (Rectangle -> Maybe Natural -> Rectangle)
-> Lens Rectangle Rectangle (Maybe Natural) (Maybe Natural)
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 :: (Maybe Natural -> f (Maybe Natural)) -> Rectangle -> f Rectangle
rectangle_y = (Rectangle -> Maybe Natural)
-> (Rectangle -> Maybe Natural -> Rectangle)
-> Lens Rectangle Rectangle (Maybe Natural) (Maybe Natural)
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 Core.FromJSON Rectangle where
  parseJSON :: Value -> Parser Rectangle
parseJSON =
    String -> (Object -> Parser Rectangle) -> Value -> Parser Rectangle
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Rectangle"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural -> Maybe Natural -> Maybe Natural -> Rectangle
Rectangle'
            (Maybe Natural
 -> Maybe Natural -> Maybe Natural -> Maybe Natural -> Rectangle)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural -> Maybe Natural -> Maybe Natural -> Rectangle)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"height")
            Parser
  (Maybe Natural -> Maybe Natural -> Maybe Natural -> Rectangle)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> Maybe Natural -> Rectangle)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"width")
            Parser (Maybe Natural -> Maybe Natural -> Rectangle)
-> Parser (Maybe Natural) -> Parser (Maybe Natural -> Rectangle)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"x")
            Parser (Maybe Natural -> Rectangle)
-> Parser (Maybe Natural) -> Parser Rectangle
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"y")
      )

instance Prelude.Hashable Rectangle

instance Prelude.NFData Rectangle

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"height" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
height,
            (Text
"width" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
width,
            (Text
"x" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
x,
            (Text
"y" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
y
          ]
      )