psychos.visual.BorderedRectangle#
- class psychos.visual.BorderedRectangle(position: Tuple[float, float] = (0, 0), width: float | None = None, height: float | None = None, border: float | None = None, color: ColorType | None = None, border_color: ColorType | None = None, window: Window | None = None, coordinates: UnitType | Unit | None = None, anchor_x: AnchorHorizontal = 'center', anchor_y: AnchorVertical = 'center', rotation: float = 0, **kwargs)[source]#
Bases:
BorderedRectangle- __init__(position: Tuple[float, float] = (0, 0), width: float | None = None, height: float | None = None, border: float | None = None, color: ColorType | None = None, border_color: ColorType | None = None, window: Window | None = None, coordinates: UnitType | Unit | None = None, anchor_x: AnchorHorizontal = 'center', anchor_y: AnchorVertical = 'center', rotation: float = 0, **kwargs)[source]#
A rectangle shape that can be drawn on the screen.
- Parameters:
position (Tuple[float, float], default=(0, 0)) – The position of the rectangle in the window.
width (Optional[float], default=None) – The width of the rectangle, in the units of the window or the given coordinates.
height (Optional[float], default=None) – The height of the rectangle, in the units of the window or the given coordinates.
border (float, default=1.0) – The width of the border of the rectangle.
color (Optional[ColorType], default=None) – The color of the rectangle.
border_color (Optional[ColorType], default=None) – The color of the border of the rectangle.
window (Optional[Window], default=None) – The window in which the rectangle will be displayed.
coordinates (Optional[Union[UnitType, Unit]], default=None) – The unit system to be used for positioning the rectangle.
anchor_x (AnchorHorizontal, default="center") – The horizontal anchor alignment of the rectangle.
anchor_y (AnchorVertical, default="center") – The vertical anchor alignment of the rectangle.
rotation (float, default=0) – The rotation angle of the rectangle (in degrees from 0-360).
kwargs (dict) – Additional keyword arguments to pass to the Pyglet Rectangle.
Methods
__init__([position, width, height, border, ...])A rectangle shape that can be drawn on the screen.
delete()Force immediate removal of the shape from video memory.
draw()Debug method to draw a single shape at its current position.
get_shape_group()Creates and returns a group to be used to render the shap[e.
Attributes
anchor_positionGet/set the anchor's
(x, y)offset fromposition.anchor_xGet/set the X coordinate of the anchor point.
anchor_yGet/set the Y coordinate of the anchor point.
batchGet/set the
Batchfor this shape.blend_modeThe current blend mode applied to this shape.
The border thickness of the bordered rectangle.
Get/set the bordered rectangle's border color.
Get/set the bordered rectangle's interior fill color.
Get the coordinate system used for the text.
groupGet/set the shape's
Group.Get/set the height of the bordered rectangle.
opacityGet/set the blend opacity of the shape.
Get the position of the text in pixels.
programThe current shader program.
rotationGet/set the shape's clockwise rotation in degrees.
visibleGet/set whether the shape will be drawn at all.
Get/set width of the bordered rectangle.
xGet/set the X coordinate of the shape's
position.yGet/set the Y coordinate of the shape's
position.zGet/set the Z coordinate of the shape.
- property border: float#
The border thickness of the bordered rectangle.
This extends inward from the edge of the rectangle toward the center.
- property border_color: tuple[int, int, int, int]#
Get/set the bordered rectangle’s border color.
To set the color of the interior fill, see
color.You can set the border color to either of the following:
An RGBA tuple of integers
(red, green, blue, alpha)An RGB tuple of integers
(red, green, blue)
Setting the alpha on this property will change the alpha of the entire shape, including both the fill and the border.
Each color component must be in the range 0 (dark) to 255 (saturated).
- property color: tuple[int, int, int, int] | tuple[int, int, int]#
Get/set the bordered rectangle’s interior fill color.
To set the color of the border outline, see
border_color.The color may be specified as either of the following:
An RGBA tuple of integers
(red, green, blue, alpha)An RGB tuple of integers
(red, green, blue)
Setting the alpha through this property will change the alpha of the entire shape, including both the fill and the border.
Each color component must be in the range 0 (dark) to 255 (saturated).
- draw() BorderedRectangle[source]#
Debug method to draw a single shape at its current position.
Warning
Avoid this inefficient method for everyday use!
Regular drawing should add shapes to a
Batchand call itsdraw()method.