campy.graphics.gtypes module¶
Exported types for representing points, dimensions, and rectangles.
A GPoint
represents an (x, y) pair and defaults to (0, 0).
A GDimension
represents a (width, height) pair and defaults to (0, 0).
A GRectangle
represents an (x, y, width, height) quadruplet and
defaults to (0, 0, 0, 0).
Named attributes are accessible for each of these types:
point = GPoint(4, 1)
print(point.x, point.y) # => 4, 1
size = GDimension(41, 574)
print(size.width, size.height) # => 41, 574
rect = GRectangle(4, 1, 41, 574)
print(rect.x, rect.y, rect.width, rect.height) # => 4, 1, 41, 574
Each of these types can also be unpacked like a tuple.
point = GPoint(4, 1) x, y = point
size = GDimension(41, 574) width, height = size
rect = GRectangle(4, 1, 41, 574) x, y, width, height = rect
Lastly, each of these types is immutable.
-
class
campy.graphics.gtypes.
GPoint
¶ Bases:
tuple
Graphical representation of an (x, y) point defaulting to (0, 0).
-
x
¶ The x-coordinate (in pixels).
-
y
¶ The y-coordinate (in pixels).
-
-
class
campy.graphics.gtypes.
GDimension
¶ Bases:
tuple
Graphical representation of a size (width, height) defaulting to (0, 0).
-
empty
()¶ Return whether this rectangle is empty.
-
height
¶ The height (in pixels).
-
width
¶ The width (in pixels).
-
-
class
campy.graphics.gtypes.
GRectangle
¶ Bases:
tuple
Graphical rectangle with upper-left corner (x, y) and size (width, height).
A
GRectangle
is often used to represent the bounding box of a graphical object.-
empty
()¶ Return whether this rectangle is empty.
-
height
¶ The height of this rectangle (in pixels).
-
width
¶ The width of this rectangle (in pixels).
-
x
¶ The x-coordinate of the upper left corner (in pixels).
-
y
¶ The y-coordinate of the upper left corner (in pixels).
-