本文整理匯總了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)