Skip to main content

There are 3 common rectangle formats, and converting them all the time really is a pain in the a**

Project description

There are 3 common rectangle formats, and converting them all the time really is a pain in the a**

Using this function, you get all 3 formats, center coordinates, height, width and the area

# Tested with:
# Python 3.9.13
# Windows 10

pip install get-rectangle-infos

from get_rectangle_infos import get_rectangle_information

format_1x4 = (0, 0, 100, 200)
format_4x2 = [(0, 0), (100, 0), (100, 200), (0, 200)]
format_2x2 = [(0, 0), (100, 200)]

print(get_rectangle_information(rect=(0, 0, 100, 200)))
# Rect(format_1x4=(0, 0, 100, 200), format_4x2=[(0, 0), (100, 0), (100, 200), (0, 200)], format_2x2=[(0, 0), (100, 200)], height=200, width=100, area=20000, center=(50, 100))

print(get_rectangle_information(rect=[(0, 0), (100, 0), (100, 200), (0, 200)]))
# Rect(format_1x4=(0, 0, 100, 200), format_4x2=[(0, 0), (100, 0), (100, 200), (0, 200)], format_2x2=[(0, 0), (100, 200)], height=200, width=100, area=20000, center=(50, 100))

print(get_rectangle_information(rect=[(0, 0), (100, 200)]))
# Rect(format_1x4=(0, 0, 100, 200), format_4x2=[(0, 0), (100, 0), (100, 200), (0, 200)], format_2x2=[(0, 0), (100, 200)], height=200, width=100, area=20000, center=(50, 100))



	

Project details


Release history Release notifications | RSS feed

This version

0.10

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

get_rectangle_infos-0.10.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

get_rectangle_infos-0.10-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page