def fract_from_image(self, pos: ImagePixelCoordinate) -> FractionalImagePos: img = self.image.image img_size = (1, 1) if img: img_size = (img.width, img.height) return FractionalImagePos.from_ImagePixelCoordinate(pos, img_size)
def size(self, value: ImagePixelCoordinate): ipc2 = ImagePixelCoordinate(0, 0) img_size = self.images[0].size() fips = [ FractionalImagePos.from_ImagePixelCoordinate(pos, img_size) for pos in (value, ipc2) ] xform = self.images[0].transform cps = [CanvasPos.from_FractionalImagePos(pos, xform) for pos in fips] width = abs(cps[1].x - cps[0].x) height = abs(cps[1].y - cps[0].y) self.right = 0.5 * width self.left = -self.right self.bottom = 0.5 * height self.top = -self.bottom