(*, pos=0, pos2=None, size=None, align=0, rint=False, color=1, alpha=1, rounding=0)
| 375 | #---------------------------------------------------------------------------- |
| 376 | |
| 377 | def draw_rect(*, pos=0, pos2=None, size=None, align=0, rint=False, color=1, alpha=1, rounding=0): |
| 378 | assert pos2 is None or size is None |
| 379 | pos = np.broadcast_to(np.asarray(pos, dtype='float32'), [2]) |
| 380 | pos2 = np.broadcast_to(np.asarray(pos2, dtype='float32'), [2]) if pos2 is not None else None |
| 381 | size = np.broadcast_to(np.asarray(size, dtype='float32'), [2]) if size is not None else None |
| 382 | size = size if size is not None else pos2 - pos if pos2 is not None else np.array([1, 1], dtype='float32') |
| 383 | pos = pos - size * align |
| 384 | if rint: |
| 385 | pos = np.rint(pos) |
| 386 | rounding = np.broadcast_to(np.asarray(rounding, dtype='float32'), [2]) |
| 387 | rounding = np.minimum(np.abs(rounding) / np.maximum(np.abs(size), 1e-8), 0.5) |
| 388 | if np.min(rounding) == 0: |
| 389 | rounding *= 0 |
| 390 | vertices = _setup_rect(float(rounding[0]), float(rounding[1])) |
| 391 | draw_shape(vertices, mode=gl.GL_TRIANGLE_FAN, pos=pos, size=size, color=color, alpha=alpha) |
| 392 | |
| 393 | @functools.lru_cache(maxsize=10000) |
| 394 | def _setup_rect(rx, ry): |
no test coverage detected