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_position

Get/set the anchor's (x, y) offset from position.

anchor_x

Get/set the X coordinate of the anchor point.

anchor_y

Get/set the Y coordinate of the anchor point.

batch

Get/set the Batch for this shape.

blend_mode

The current blend mode applied to this shape.

border

The border thickness of the bordered rectangle.

border_color

Get/set the bordered rectangle's border color.

color

Get/set the bordered rectangle's interior fill color.

coordinates

Get the coordinate system used for the text.

group

Get/set the shape's Group.

height

Get/set the height of the bordered rectangle.

opacity

Get/set the blend opacity of the shape.

position

Get the position of the text in pixels.

program

The current shader program.

rotation

Get/set the shape's clockwise rotation in degrees.

visible

Get/set whether the shape will be drawn at all.

width

Get/set width of the bordered rectangle.

x

Get/set the X coordinate of the shape's position.

y

Get/set the Y coordinate of the shape's position.

z

Get/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).

property coordinates: Unit#

Get the coordinate system used for the text.

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 Batch and call its draw() method.

property height: float#

Get/set the height of the bordered rectangle.

The bottom and top of the rectangle will be positioned relative to its anchor_y value.

property position: Tuple[float, float]#

Get the position of the text in pixels.

property width: float#

Get/set width of the bordered rectangle.

The new left and right of the rectangle will be set relative to its anchor_x value.