anim.plane.rectangle¶
- class anim.plane.rectangle(Lx=None, Ly=None, dimension=None, center=[True, True], color='grey', stroke=None, thickness=0, linestyle='-', group=None, x=0, y=0, position=None, center_of_rotation=[0, 0], orientation=0, zvalue=0, draggable=False, clickable=False)¶
A rectangle item is defined by its:
dimensions (width and height)
position of the point of reference
- horizontal and vertical centering, with respect to the point of
reference. The defaut centering is (True,True), while (False,False) defines the reference as the bottom-left corner. One can also use a single value to set both at the same time.
styling
Parameters ══════════
- name
str The rectangle’s name
- group
anim.plane.group default: None The rectangle’s group. If None, the position of the reference point and center of rotation are in absolute coordinates. Otherwise, the position is relative to the group’s reference point.
─── dimensions ──────────────────────────────
- Lx
float The rectangle’s width, i.e. length along the x axis when orientation is 0.
- Ly
float The rectangle’s height, i.e.length along the y axis when orientation is 0.
- dimension
(float, float), [float, float], complex default: [0,0] Dimensions along the x and y axes when orientation is 0. The user must define either Lx, Ly or the dimension array. In case of conflicting definitions, the dimension attribute wins.
─── position ────────────────────────────────
- x
float default: 0 x-position of the reference point.
- y
float default: 0 y-position of the reference point.
- position
(float, float), [float, float], complex default: [0,0] Position of the reference point. The user can define either x, y or the position. In case of conflict, the position attribute wins.
- center
(bool, bool), [bool, bool], bool default: [True,True] Boolean defining the centering around the reference point. For tuple and list the first element is for the x-axis and the second is for the y-axis.
─── transformations ─────────────────────────
- orientation
float default: 0, unit: radians Orientation of the rectangle, with respect to the positive part of the x-axis.
- center_of_rotation
(float, float), [float, float], complex default: None Center point for the rotation.
- draggable
bool default: False Boolean specifying if the item can be dragged. If True, the dragging callback is defined in the ‘itemChange’ method of the event class, which is transfered to the canva’s ‘event’ method (recommended).
─── stack ───────────────────────────────────
- zvalue
float default: 0 Z-value (stack order) of the rectangle.
─── style ────────────────────────────────
- color
None, str, QColor default: ‘grey’ Fill color. None stands for transparency.
- stroke
None, str, QColor default: None Stroke color. None stands for transparency.
- thickness
float default: 0 Stroke thickness, in scene units. When it is equal to 0, the stroke has the minimal thickness of 1 pixel.
- linestyle
‘solid’/’-’, ‘dash’/’–’, ‘dot’/’..’/’:’, ‘dashdot’/’-.’ default: ‘-’ Stroke style.
- __init__(Lx=None, Ly=None, dimension=None, center=[True, True], color='grey', stroke=None, thickness=0, linestyle='-', group=None, x=0, y=0, position=None, center_of_rotation=[0, 0], orientation=0, zvalue=0, draggable=False, clickable=False)¶
Rectangle item constructor
Methods
__init__([Lx, Ly, dimension, center, color, ...])Rectangle item constructor
initialize()Initialize the rectangle
rotate(angle)Relative rotation
setColor()Color styling
setGeometry()Set the rectangle's geometry
setOrientation()Set the qitem orientation
setPosition([position])Sets the qitem's position.
setStroke()Stroke styling
translate(dx[, dy])Relative translation
Attributes
LxLycentercenter_of_rotationclickablecolordimensiondraggablegrouplinestyleorientationpositionstrokethicknessxyzvalue