Duncan Tourolle ea93681aaf
All checks were successful
Python CI / test (push) Successful in 6m46s
refactoring the mixin system
2025-11-08 08:08:02 +01:00

33 lines
1.1 KiB
Python

from __future__ import annotations
import numpy as np
from PIL import Image
from typing import Tuple, Union, List, Optional, Dict
from pyWebLayout.core.base import Renderable, Queriable
from pyWebLayout.core import Geometric
from pyWebLayout.style import Alignment
class Box(Geometric, Renderable, Queriable):
"""
A box with geometric properties (origin and size).
Uses Geometric mixin for origin and size management.
"""
def __init__(self,origin, size, callback = None, sheet : Image = None, mode: bool = None, halign=Alignment.CENTER, valign = Alignment.CENTER):
super().__init__(origin=origin, size=size)
self._end = self._origin + self._size
self._callback = callback
self._sheet : Image = sheet
if self._sheet == None:
self._mode = mode
else:
self._mode = sheet.mode
self._halign = halign
self._valign = valign
# origin and size properties are provided by Geometric mixin
def in_shape(self, point):
return np.all((point >= self._origin) & (point < self._end), axis=-1)