def test_pattern_offset(): pt = Pattern("mixin.L50B50.png") assert pt.offset == (-0.5, 0.5) pt = Pattern("mixin.T50R50.png") assert pt.offset == (0.5, -0.5) pt = Pattern("mixin.T50R50.png") assert pt.offset == (0.5, -0.5)
def pattern_open(self, image): if isinstance(image, Pattern): if image._image is None: image_path = self._search_image(image._name) image._image = imutils.open(image_path) return image elif isinstance(image, basestring): image_path = base.search_image(image, self.image_path) if image_path is None: raise IOError('image file not found: {}'.format(image)) return Pattern(image_path, image=imutils.open(image_path)) elif 'numpy' in str(type(image)): return Pattern('unknown', image=image) else: raise TypeError("Not supported image type: {}".format(type(image)))
def pattern_open(self, image): if self.__screensize is None: self.__screensize = self.display if isinstance(image, Pattern): if image._image is None: image._image = self._open_image_file(image._name) return image if isinstance(image, six.string_types): path = image return Pattern(path, image=self._open_image_file(path)) if 'numpy' in str(type(image)): return Pattern('unknown', image=image) raise TypeError("Not supported image type: {}".format(type(image)))
def pattern_open(self, image): if self.__screensize is None: self.__screensize = self.display if isinstance(image, Pattern): if image._image is None: image_path = self._search_image(image._name) image._image = imutils.open(image_path) return image if isinstance(image, basestring): image_path = base.lookup_image(image, self.__screensize[0], self.__screensize[1]) if image_path is None: raise IOError('file not found: {}'.format(image)) return Pattern(image_path, image=imutils.open(image_path)) if 'numpy' in str(type(image)): return Pattern('unknown', image=image) raise TypeError("Not supported image type: {}".format(type(image)))
def pattern_open(path): return Pattern('unknown', image=imutils.open(path))