本文整理汇总了Python中rectangle.Rectangle.find_center方法的典型用法代码示例。如果您正苦于以下问题:Python Rectangle.find_center方法的具体用法?Python Rectangle.find_center怎么用?Python Rectangle.find_center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rectangle.Rectangle
的用法示例。
在下文中一共展示了Rectangle.find_center方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from rectangle import Rectangle [as 别名]
# 或者: from rectangle.Rectangle import find_center [as 别名]
def main():
house = Point(10, 9)
print('House is at X:', house.x)
print('House is at Y:', house.y)
work = Point(5, 2)
print('House to work distance:', house.distance_to(work))
city = Rectangle(Point(5, 5), 10, 10)
print('City corner is:', city.bottom_left_corner)
print('City width:', city.w)
print('City height:', city.h)
print('House in city:', city.contains(house))
print('Work in city:', city.contains(work))
city_center = city.find_center()
print('City center:', city_center)
cats_house = Point(10, 9)
identical_city = Rectangle(Point(5, 5), 10, 10)
different_city = Rectangle(Point(13, 13), 10, 10)
print("My cat's house and mine are equal:", house == cats_house)
print('Two identical cities are equal:', city == identical_city)
print('Two different cities are equal:', city == different_city)
house.move_by(1, -1)
print('After moving my house:', house)