



'''simple docstring'''

import math



def      __lowerCamelCase     (      )			->      None:
		_a     :      str        =							input('Enter message: '  )
		_a     :      int        =							int(input(f"""Enter key [2-{len(lowerCAmelCase_  ) - 1}]: """  )  )
		_a     :      List[str]        =							input('Encryption/Decryption [e/d]: '  )

		if mode.lower().startswith('e'  ):
				_a     :      str        =							encrypt_message(lowerCAmelCase_						,			lowerCAmelCase_  )
		elif mode.lower().startswith('d'  ):
				_a     :      Union[str, Any]        =							decrypt_message(lowerCAmelCase_						,			lowerCAmelCase_  )

		# Append pipe symbol (vertical bar) to identify spaces at the end.
		print(f"""Output:\n{text + '|'}"""  )



def      __lowerCamelCase     (      lowerCAmelCase_						,			lowerCAmelCase_  )			->      str:
		_a     :      List[Any]        =							[''] * key
		for col in range(lowerCAmelCase_  ):
				_a     :      Optional[Any]        =							col
				while pointer < len(lowerCAmelCase_  ):
						cipher_text[col] += message[pointer]
						pointer += key
		return "".join(lowerCAmelCase_  )



def      __lowerCamelCase     (      lowerCAmelCase_						,			lowerCAmelCase_  )			->      str:
		_a     :      Optional[int]        =							math.ceil(len(lowerCAmelCase_  ) / key  )
		_a     :      Optional[Any]        =							key
		_a     :      int        =							(num_cols * num_rows) - len(lowerCAmelCase_  )
		_a     :      Optional[Any]        =							[''] * num_cols
		_a     :      Any        =							0
		_a     :      Dict        =							0

		for symbol in message:
				plain_text[col] += symbol
				col += 1

				if (
				    (col == num_cols)
				    or (col == num_cols - 1)
				    and (row >= num_rows - num_shaded_boxes)
				):
						_a     :      Dict        =							0
						row += 1

		return "".join(lowerCAmelCase_  )


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							main()









'''simple docstring'''

from pathlib import Path

import cva
import numpy as np
from matplotlib import pyplot as plt



def      __lowerCamelCase     (      lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_						,			lowerCAmelCase_  )			->      np.ndarray:
		_a     :      Union[str, Any]        =							cva.getAffineTransform(lowerCAmelCase_						,			lowerCAmelCase_  )
		return cva.warpAffine(lowerCAmelCase_						,			lowerCAmelCase_						,			(rows, cols)  )


if __name__ == "__main__":
							# read original image
							__lowerCAmelCase									=   cva.imread(
							    str(Path(__file__).resolve().parent.parent / '''image_data''' / '''lena.jpg''')
							)
							# turn image in gray scale value
							__lowerCAmelCase									=   cva.cvtColor(image, cva.COLOR_BGR2GRAY)
							# get image shape
							__lowerCAmelCase			,					__lowerCAmelCase									=   gray_img.shape

							# set different points to rotate image
							__lowerCAmelCase									=   np.array([[50, 50], [200, 50], [50, 200]], np.floataa)
							__lowerCAmelCase									=   np.array([[10, 100], [200, 50], [100, 250]], np.floataa)
							__lowerCAmelCase									=   np.array([[50, 50], [150, 50], [120, 200]], np.floataa)
							__lowerCAmelCase									=   np.array([[10, 100], [80, 50], [180, 250]], np.floataa)

							# add all rotated images in a list
							__lowerCAmelCase									=   [
							    gray_img,
							    get_rotation(gray_img, ptsa, ptsa, img_rows, img_cols),
							    get_rotation(gray_img, ptsa, ptsa, img_rows, img_cols),
							    get_rotation(gray_img, ptsa, ptsa, img_rows, img_cols),
							]

							# plot different image rotations
							__lowerCAmelCase									=   plt.figure(1)
							__lowerCAmelCase									=   ['''Original''', '''Rotation 1''', '''Rotation 2''', '''Rotation 3''']
							for i, image in enumerate(images):
														plt.subplot(2, 2, i + 1), plt.imshow(image, '''gray''')
														plt.title(titles[i])
														plt.axis('''off''')
														plt.subplots_adjust(left=0.0, bottom=0.05, right=1.0, top=0.95)
							plt.show()




