Rect2D
Rect2D
represents a rectangle in two-dimensional space. The rect2d
component is always defined by a 4-element list,
with one of several representations:
- XYWH =
[x, y, w, h]
, with x,y = left,top. - YXHW =
[y, x, h, w]
, with x,y = left,top. - XYXY =
[x0, y0, x1, y1]
, with x0,y0 = left,top and x1,y1 = right,bottom - YXYX =
[y0, x0, y1, x1]
, with x0,y0 = left,top and x1,y1 = right,bottom - XCYCWH =
[x_center, y_center, width, height]
- XCYCW2H2 =
[x_center, y_center, width/2, height/2]
It is compatible with AnnotationContext
. class_id
can be used to provide
colors and labels from the annotation context. See examples in the
AnnotationContext
documentation.
draw_order
can be used to control how the Rect2D
entities are drawn relative to other objects within the scene. Higher values are drawn on top of lower values.
Components and APIs
Primary component: rect2d
,
Secondary components: colorrgba
, radius
, label
, classid
, draw_order
Python APIs: log_rect, log_rects
Rust API: Rect2D
Simple Example
"""Log a simple rectangle.""" import rerun as rr rr.init("rerun_example_rect2d", spawn=True) rr.log_rect("simple", [-1, -1, 2, 2], rect_format=rr.RectFormat.XYWH) # Log an extra rect to set the view bounds rr.log_rect("bounds", [0, 0, 4, 3], rect_format=rr.RectFormat.XCYCWH)
