rectangles module#

class Rect(cx, cy, w, h, fill, role, angle=0.0)[source]#
Parameters:
cx: float#
cy: float#
w: float#
h: float#
fill: str#
role: str#
angle: float = 0.0#
compute_led_orientations(rects, width, height, led_diam=6.0, led_extra=2.0, clearance=0.25, rng=None)[source]#

Assign Rect.angle so Øled_diam + led_extra tail avoids edges/other LEDs. Coordinates are JITX (y-up).

Return type:

None

Parameters:
validate_led_layout(rects, width, height, led_diam=6.0, led_extra=2.0, clearance=0.25)[source]#

Return list of violations (empty if OK). Coordinates are JITX (y-up).

Return type:

List[str]

Parameters:
mondrian_bsp(width=180.0, height=300.0, line_thickness=3.0, min_size=22.0, target_count=70, irregularity=0.35, avoid_align_eps=1.5, role_weights=None, colors=None, seed=None, snap_step=0.25, led_diam=6.0, led_extra=2.0, led_clearance=0.25, led_count=None)[source]#

Mondrian-ish BSP subdivision. Returns rectangles only, in JITX coords (y-up).

Parameters:
  • width (float) – Board width in mm

  • height (float) – Board height in mm

  • line_thickness (float) – Thickness of lines between rectangles

  • min_size (float) – Minimum rectangle size

  • target_count (int) – Target number of rectangles to generate

  • irregularity (float) – How irregular the splits should be (0.0-1.0)

  • avoid_align_eps (float) – Minimum distance between split lines

  • role_weights (Optional[Dict[str, float]]) – Probability weights for rectangle roles (mask, void, led)

  • colors (Optional[Dict[str, str]]) – Colors for each role type

  • seed (Optional[int]) – Random seed for reproducible results

  • snap_step (float) – Grid snapping step size

  • led_diam (float) – LED diameter for clearance calculations

  • led_extra (float) – LED tail length for clearance calculations

  • led_clearance (float) – Minimum clearance around LEDs

  • led_count (Optional[int]) – Exact number of LEDs to generate (if specified, overrides probability-based assignment)

Return type:

List[Rect]

Returns:

List of Rect objects with assigned roles and orientations