MCPcopy Index your code
hub / github.com/JacquesLucke/code_autocomplete / Rectangle

Class Rectangle

graphics.py:69–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67 glColor4f(0.0, 0.0, 0.0, 1.0)
68
69class Rectangle:
70 # (x, y) is the top left corner
71 def __init__(self, x, y, width, height):
72 self.left = x
73 self.right = x + width
74 self.top = y
75 self.bottom = y - height
76
77 def move_down(self, amount):
78 self.top -= amount
79 self.bottom -= amount
80
81 @property
82 def width(self):
83 return self.right - self.left
84 @property
85 def height(self):
86 return self.top - self.bottom
87
88 @property
89 def center(self):
90 return [(self.left+self.right) / 2, (self.top+self.bottom) / 2]
91
92 @property
93 def top_left(self):
94 return [self.left, self.top]
95
96 def contains(self, x, y):
97 return self.left <= x <= self.right and self.top >= y >= self.bottom
98
99 def get_inset_rectangle(self, border):
100 return Rectangle(self.left + border, self.top - border, self.width - 2*border, self.height - 2*border)
101
102 def __repr__(self):
103 return "(Left: "+str(self.left)+", Right: "+str(self.right)+", Top: "+str(self.top)+", Bottom: "+str(self.bottom)+")"
104
105class Label:
106 def __init__(self):

Callers 9

__init__Method · 0.85
draw_operator_boxMethod · 0.85
draw_description_boxMethod · 0.85
get_inset_rectangleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected