示例#1
0
    def __init__(self, size=None, img=None, unit=1):
        self.unit = t2(unit)

        if img is not None:
            iw, ih = img.size
            ux, uy = self.unit
            assert iw % ux == 0, 'image width is not divisible by unit'
            assert ih % uy == 0, 'image height is not divisible by unit'
            self.size = (iw // ux, ih // uy)
            self._img = img
        else:
            px_size = tuple(u * s for u, s in zip(self.unit, size))
            self.size = size
            self._img = img or CachedImage.blank(px_size)

        self.px_size = self._img.size
示例#2
0
    def __init__(self, size=None, img=None, unit=1):
        self.unit = t2(unit)

        if img is not None:
            iw, ih = img.size
            ux, uy = self.unit
            assert iw % ux == 0, 'image width is not divisible by unit'
            assert ih % uy == 0, 'image height is not divisible by unit'
            self.size = (iw // ux, ih // uy)
            self._img = img
        else:
            px_size = tuple(u * s for u,s in zip(self.unit, size))
            self.size = size
            self._img = img or CachedImage.blank(px_size)

        self.px_size = self._img.size